1

I would like to initialize a date object in JS using local date string format, e.g.:

var d = new Date("ma, 14 tammi 2013 10:56:19 +0200"); //invalid Date

How is it possible to do so?

nagy.zsolt.hun
  • 6,292
  • 12
  • 56
  • 95
  • 1
    You should have a look at this thread: http://stackoverflow.com/questions/1056728/formatting-a-date-in-javascript – clement g Jan 14 '13 at 13:02
  • You should try this way var d1 = new Date("October 13, 1975 11:13:00"); var t = d1.toString(); var d2 = new Date(t); d2.toString(); – THE ONLY ONE Jan 14 '13 at 13:03
  • 3
    Don't use locale date strings to pass time data around, use unix timestamps or UTC dates, and then format for display – Esailija Jan 14 '13 at 13:17
  • The Date() object only accepts Gregorian Calendar Dates as input. It cannot recognise other calendar dates as inputs – Mohsen Alyafei Feb 26 '22 at 09:44

0 Answers0