Javascript转换yyyy-mm-dd hh:mm:ss like newDate(“day,month date year hh:mm:ss”) [英] Javascript convert yyyy-mm-dd hh:mm:ss like newDate("day, month date year hh:mm:ss")

查看:166
本文介绍了Javascript转换yyyy-mm-dd hh:mm:ss like newDate(“day,month date year hh:mm:ss”)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在上使用日期对象方法 getHoures(),getSeconds() ...) Date(string)(string = month day,year hh:mm:ss ),但我的日期格式如下所示: yyyy-mm-dd hh:mm:ss

I want to use Date Object Methods (getHoures(), getSeconds()...) on new Date("string") (string = month day, year hh:mm:ss) but my date format is like this : yyyy-mm-dd hh:mm:ss

所以我需要转换yyyy-mm-dd hh:mm:ss to(day,month date year hh:mm:ss

So I need to convert "yyyy-mm-dd hh:mm:ss" to "("day, month date year hh:mm:ss")"

请问吗?

Thx!

推荐答案

其实,您需要执行任何此类转换。

Actually, you don't need to perform any such conversion.

您所拥有的字符串已经很接近 新的可接受的格式日期(字符串)事实上,即使是大部分(如果不是全部)现代浏览器也将被接受。

The string you have is already in very nearly an acceptable format for new Date(string) and in fact even as is will be accepted by most (if not all) modern browsers.

使其完全符合使用ES5规定的ISO8601变体,只需将日期和时间之间的空格替换为文字 T 字符,并在末尾添加时区说明符(例如, code> Z 为UTC,或 +01:00 ,例如)。

To make it fully compliant with the ISO8601 variant that ES5 mandates, just replace the space between the date and time with a literal T character, and add a time-zone specifier at the end (e.g. either Z for UTC, or +01:00, for example).

请参阅 http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.15 更多。

这篇关于Javascript转换yyyy-mm-dd hh:mm:ss like newDate(“day,month date year hh:mm:ss”)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆