public static object GetUnixTime(string date)
{
var offset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).Hours;
var origin = new DateTime(1970, 1, 1);
DateTime dateTime;
if (DateTime.TryParse(date, out dateTime))
{
var diff = (dateTime.Subtract(origin.AddHours(offset))).TotalSeconds;
return diff;
}
return false;
}
Although I'm sure there's more to this story that I'm missing, this method appears to be a great replacement for the Phalanger methods related to the PHP function "strtotime".
Specifically, I kept encountering the issue that a "null" MySQL time (0000-00-00 00:00:00) throws an exception in Phalanger that the monthNum must between 1 and 12. (No idea why anyone would use the zero string instead of a real NULL, but I use what I'm given....)
Anyway, hope that helps give someone a better idea of how to tackle this in the Phalanger base code.
Thank you,
Mike