Ryan Ramsey wrote:
> I am trying to convert a value returned from the date() function in php 5.0
> to a format .NET can use.
>
> DateTime dt_now = DateTime.Now;
> DateTime dt_last = new DateTime(Convert.ToInt32(dkpLast[0][1]));
> TimeSpan dt_diff = dt_now.Subtract(dt_last);
>
> the value returned to dt_last is 1153455444 which is rougly July 20th ~ 10pm
>
> When I compare this to dt_diff I get a delta value (via dt_diff.Days) of
> roughly 73,000 days.
According to the documentation for PHP, the number you're talking about
is the number of seconds since the first of January 1970 - whereas the
constructor you're using is taking ticks (not seconds) since the first
of January 1AD.
Here's some code to convert the seconds you've got into a DateTime:
DateTime epoch = new DateTime(1970, 1, 1);
DateTime date = epoch.AddSeconds(1153455444);
Jon
|