[英]How can I format a date in javascript without using moment.js
I am trying to convert my date object to mm/dd/yy hh/mm我正在尝试将我的日期对象转换为 mm/dd/yy hh/mm
newDateObj = new Date(dateString).toLocaleString();
Output is 12/7/1913, 1:31:52 PM but i dont want the seconds.输出是 12/7/1913, 1:31:52 PM 但我不想要秒。
You can use MomentJS and combine moment("1913-12-07T17:41:52").format('L'); // 12/07/1913
您可以使用MomentJS并结合moment("1913-12-07T17:41:52").format('L'); // 12/07/1913
moment("1913-12-07T17:41:52").format('L'); // 12/07/1913
with moment("1913-12-07T17:41:52").format('LT'); // 5:41 AM
moment("1913-12-07T17:41:52").format('L'); // 12/07/1913
with moment("1913-12-07T17:41:52").format('LT'); // 5:41 AM
moment("1913-12-07T17:41:52").format('LT'); // 5:41 AM
I got it working without momentum我让它在没有动力的情况下工作
var options = {month: '2-
digit', day: '2-digit', year: '2-digit',hour: '2-digit', minute:'2-digit'};
newDateObj= new Date(dateString).toLocaleString([], options );
Output is 12/7/1913, 1:31:52 PM输出时间为 12/7/1913,下午 1:31:52
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.