how to get formatted date time like 2009-05-29 21:55:57 using javascript?

前端 未结 10 1250
轮回少年
轮回少年 2021-02-01 14:33

when using new Date,I get something like follows:

Fri May 29 2009 22:39:02 GMT+0800 (China Standard Time)

but what I want is xxxx-xx-xx xx:xx:xx formatted time s

10条回答
  •  走了就别回头了
    2021-02-01 15:19

    The Any+Time(TM) JavaScript Library's AnyTime.Converter object easily converts a JS Date object into ISO or virtually any other format... in fact, the format you want is the default format, so you could simply say:

    (new AnyTime.Converter()).format(new Date());
    

提交回复
热议问题