TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Brad Wickwire
NA
15
0
Find the unix timestamp for a given date
Aug 31 2007 1:16 PM
I am trying to find the unxi timestamp for a given date. I wrote the below function but it does not seem to produce accurate results. Here are the results it returns and what PHP returns. Can anyone see a problem with the code?
08/25/2007 11:43:00 AM
C# = 1188042180
PHP = 1188060180
08/25/2007 11:43:00 PM
C# = 1188085380
PHP = 1188103380
public long GetEpochTime(string dDate)
{
DateTime fDate = Convert.ToDateTime(dDate);
TimeSpan ts = (new DateTime(fDate.Year, fDate.Month, fDate.Day, fDate.Hour, fDate.Minute, fDate.Second) - new DateTime(1970, 1, 1, 0, 0, 0));
double unixTime = ts.TotalSeconds;
long lUnixTime = Convert.ToInt64(unixTime);
return lUnixTime;
}
Reply
Answers (
0
)
Merge DataSets
Question about string data