Reputation: 5027
In my MVC view, I am taking user input for date and passing that value to a controller action.
The date I am passing comes into the controller parameter with a timestamp. Later in the controller code, I am comparing that date parameter to a date value from the database. The database date value is in JSON Date format.
My questions two fold..
How to get just the date passed into the controller and not with time stamp. Or how can I convert that date format with time stamp into just mm/dd/yyyy
format.
Once I do that, how can I compare two values. One date is in regular mm/dd/yyyy
format and the other date (from database) is in JSON date format as "/Date(1324414956395)/"
Thanks in advance.
Upvotes: 1
Views: 771
Reputation: 1906
You could create a method to do it:
private static DateTime ConvertFromUnixTimestamp(double timestamp)
{
var original = new DateTime(1970, 1, 1, 0, 0, 0, 0);
return original.AddSeconds(timestamp);
}
Upvotes: 1