Last active
September 1, 2016 18:14
-
-
Save pipedreambomb/d65ec95281e598f4012bf87ba9f4ed1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<span id='date-me'></span> | |
<script type='text/JavaScript'>document.getElementById('date-me').innerHTML = new Date(Date.parse('Wed, 09 Aug 1995 00:00:00 GMT')).toLocaleString()</script> |
Update: I found Date.parse() does work with UTC as long as the string is formatted in one of a few supported ways.
I think outputting a DateTime as RoundTrip ought to do it.
https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Roundtrip
Might need to set the DateTimeKind first:
https://msdn.microsoft.com/en-us/library/system.datetime.specifykind(v=vs.110).aspx
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My idea is to write an HTML helper in ASP.NET MVC that can convert a datetime to a local date, and you don't need to do anything but supply the date.
I'll have to generate the IDs uniquely, probably by field name with some prefix or suffix.
The date information will come from the .NET DateTime object, and will need filling in slightly laboriously (as in .GetYear() .GetMonth() etc) as JavaScript doesn't seem to have a native way of parsing UTC dates, and I'd rather not use a library like moment.js so that the helper always works and has no dependencies.