new Date() is working in Chrome but not Firefox

new Date() is working in Chrome but not Firefox

Asked on December 24, 2018 in Javascript.
Add Comment


  • 3 Answer(s)

    This is the way of instantiate a date object. Try this code example,

    new Date() // current date and time
    new Date(milliseconds) //milliseconds since 1970/01/01
    new Date(dateString)
    new Date(year, month, day, hours, minutes, seconds, milliseconds)
    

    Try this also,

    d1 = new Date("October 13, 1975 11:13:00")
    d2 = new Date(79,5,24)
    d3 = new Date(79,5,24,11,33,0)
    

    The source is here. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

    The EMCAScript specification need the exact one date format.But it custom date formats may be freely supported by an implementation: “In case the String are not confirm to that  format the function may fall back to any implementation-specific heuristics .The implementation-specific date format are different in chrome and FF.

    Answered on December 24, 2018.
    Add Comment

    Here is the code,

    new Date('2001-01-31 12:00:00')
    
    

    And here is the format: YYYY-MM-DDTHH:mm:ss.sss.

    Answered on December 24, 2018.
    Add Comment

    Anyone can use this code, because it works at all browsers,

    new Date('2001/01/31 12:00:00')
    
    

    This should be the format,

    “yyyy/MM/dd HH:mm:ss”.

    Answered on December 24, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.