简体   繁体   English

在JavaScript中设置日期时间顺序

[英]Set Datetime order in JavaScript

Is there any way of manipulate datetime in JavaScript?? 有没有办法在JavaScript中操纵日期时间? I mean, I would like to get a datetime and change to this format ('DD/MM/YYYY hh:mm A/PM'). 我的意思是,我想获取一个日期时间并更改为此格式(“ DD / MM / YYYY hh:mm A / PM”)。

This is my code 这是我的代码

$('#control_day_edit').val(calEvent.start._i)

This returns me this: 01/07/2015 05:11 PM But I need it returns me this: 07/01/2015 05:11 PM 这会给我返回此信息:2015年1月7日下午05:11但我需要它是给我返回此时间:2015年7月1日下午05:11

JavaScript has virtually no built-in date/time formatting. JavaScript实际上没有内置的日期/时间格式。 Instead, you either use the individual methods of Date instances ( getHours , getMinutes , etc.) to build your string, or use a library like MomentJS which uses them for you. 相反,您可以使用Date实例的各个方法( getHoursgetMinutes等)来构建您的字符串,或者使用像MomentJS这样的库来为您使用它们。

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

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