简体   繁体   English

如何将UTC日期时间转换为其他格式

[英]How to convert UTC datetime to different format

I have a datetime string in the following format. 我有以下格式的日期时间字符串。

var datetime="Thu May 5 05:30:00 UTC+0530 2011" ; var datetime =“ Thu May 5 05:30:00 UTC + 0530 2011”;

I want to convert it in the following format. 我想将其转换为以下格式。 How can I do it in javascript 我该如何在JavaScript中做到这一点

"Thursday, 05 May 2011" “ 2011年5月5日,星期四”

The globalize plugin has date parsing and formatting features. globalize插件具有日期解析和格式化功能。

Here is an example from the plugin page: 这是插件页面上的示例:

Globalize.format( new Date(1955,10,5), "dddd MMMM d, yyyy" ); // "Saturday November 5, 1955"

The date.js library is very useful for working with Dates. date.js库对于使用日期非常有用。

Formatting examples: 格式示例:

Date.today().toString("dddd MMMM d, yyyy"); // Monday November 19, 2007
Date.today().toString();                    // native .toString() functionality
Date.today().toString("M/d/yyyy");          // 11/19/2007
Date.today().toString("d-MMM-yyyy");        // 19-Nov-2007
new Date().toString("HH:mm");               // 18:45

Parsing examples: 解析示例:

Date.parse('today');
Date.parse('t + 5 d'); // today + 5 days
Date.parse('next thursday');
Date.parse('February 20th 1973');
Date.parse('Thu, 1 July 2004 22:30:00');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM