Reputation: 2326
I have a string 2016-01-04T15:30:00
coming from c# DateTime.
When I convert it to a javascript
Date
object var jDate = new Date(2016-01-04T15:30:00);
the time is getting changed based on the local time zone
Console Output: Mon Jan 04 2016 10:30:00 GMT-0500 (Eastern Standard Time)
How can I get the date to have the time 15:30
and not 10:30
?
The answer should return a Date object so I can do date.getHours()
Upvotes: 0
Views: 990
Reputation: 73
You need to cahnge the DateTime Kind to Unspecified,
DateTime.SpecifyKind(saveNow, DateTimeKind.Unspecified);
Read more here :
https://msdn.microsoft.com/en-us/library/system.datetime.specifykind(v=vs.110).aspx
Upvotes: 1