[英]In JavaScript, How to Convert a date time value from one format to the other?
Please look at the format of these date time values: 请查看以下日期时间值的格式:
var from = "2012-01-13 T11:00:00";
var to = "13 Jan 2012 11:00am";
In the above example, how to write a javascript function which converts a value in "from" format to a value in "to" format, both are datetime values in text obvioulsy. 在上面的示例中,如何编写Javascript函数将“从”格式的值转换为“至”格式的值,这两个都是文本无效的日期时间值。
var to = convertDateTime(from);
function convertDateTime(from)
{
// how to implement this?
}
Many thanks, 非常感谢,
look at this article : http://blog.stevenlevithan.com/archives/date-time-format 看这篇文章: http : //blog.stevenlevithan.com/archives/date-time-format
you must convert your string object into date type and then retransform it to string using date format 您必须将字符串对象转换为日期类型,然后使用日期格式将其重新转换为字符串
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.