Javascript Converting human time to timestamp

前端 未结 4 605
面向向阳花
面向向阳花 2020-12-30 07:35

Using javascript, How can I convert a \"human time\" string like \"Wed Jun 20 19:20:44 +0000 2012\" into a timestamp value like \"1338821992\"?

4条回答
  •  旧巷少年郎
    2020-12-30 07:59

    In theory, with Date.parse(). In practice, however, with the thousands of different ways to express date and time (the least of which being the names of days/months in different languages), it's far easier to get the date in its component parts instead of trying to read a string.

提交回复
热议问题