I have a DateTime value stored in an SQL Server DB with a value like '2016-04-13 00:00:00.0000000'. My problem is that I want to display this value on a HTML page as is without the browser or my server adjusting for Time Zone offsets.
I make an Ajax request to get my data to an MVC controller. I can see that the value of the Date in my ViewModel is correct. When it gets to the browser depending on the machines timezone the Date is offset.
All I want is that if I have a value 2015-04-13 00:00 in my database then that exact value gets displayed on my interface regardless of timezones, locales etc.
My Ajax request returns a value like "/Date(1460502000000)/". I've tried the following conversions:
new Date(datavar);
Date(datevar)
new Date(parseInt(datevar.replace('/Date(', '')))
I've also tried using moment.js like the following:
moment.utc(datevar).format();
moment(datevar).tostring()
An several others all of which try to offset the date some way or other.
The suggested linked answer is different in that it will include the timezone offset. So a client on US Central Time a value of "/Date(1460505600000)/" will be converted to 'Tue Apr 12 2016 18:00 GMT-0500" while a client on GMT will get the same value converted to "Wed Apr 13 2016 00:00:00 GMT+0100"