Find the unix timestamp for a given date
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;
}