![]() Var mm = (d.getMonth()+1).toString() // getMonth() is zero-based Local time requires a bit more effort as there is no return a date in the same format as “toISOString” but in the client’s local timezone. UTC time is elegantly solved by this one liner as “toISOString” gives us a yyyy-mm-dd date in the first 10 characters of it’s result string: var d = new Date().toISOString().slice(0,10) User’s Local Time A lot of the JavaScript examples out there to get current date in the format yyyy-mm-dd (or dd/mm/yyyy, etc) don’t highlight the fact that they make assumptions about whether they return date as the user’s local time or UTC time. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |