jQuery getTime function

后端 未结 7 1997
时光取名叫无心
时光取名叫无心 2020-12-13 14:06

is it possible to create a jQuery function so that it gets current date and time? I\'ve been looking around documentation but haven\'t found anything so far...

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-13 14:32

    Annoyingly Javascript's date.getSeconds() et al will not pad the result with zeros 11:0:0 instead of 11:00:00.

    So I like to use

    date.toLocaleTimestring()
    

    Which renders 11:00:00 AM. Just beware when using the extra options, some browsers don't support them (Safari)

    Documentation

提交回复
热议问题