How can I convert string to datetime with format specification in JavaScript?

前端 未结 15 1218
终归单人心
终归单人心 2020-11-22 02:35

How can I convert a string to a date time object in javascript by specifying a format string?

I am looking for something like:

var dateTime = convert         


        
15条回答
  •  粉色の甜心
    2020-11-22 03:00

    I think this can help you: http://www.mattkruse.com/javascript/date/

    There's a getDateFromFormat() function that you can tweak a little to solve your problem.

    Update: there's an updated version of the samples available at javascripttoolbox.com

提交回复
热议问题