How to get current time with jQuery

后端 未结 15 877
青春惊慌失措
青春惊慌失措 2020-12-07 08:10

The following returns time in microseconds, for example 4565212462.

alert( $.now() );

How do I convert it to a human readable time format,

15条回答
  •  青春惊慌失措
    2020-12-07 08:40

    For local time in ISO8601 for SQL TIMESTAMP you could try:

    var tzoffset = (new Date()).getTimezoneOffset() * 60000;
    var localISOTime = (new Date(Date.now() - tzoffset))
      .toISOString()
      .slice(0, 19)
      .replace('T', ' ');
    $('#mydatediv').val(localISOTime);
    

提交回复
热议问题