如何使用jquery将yyyy-mm-dd格式化日期转换为“长日期”格式? [英] How to convert yyyy-mm-dd formatted date to 'long date' format using jquery?

查看:396
本文介绍了如何使用jquery将yyyy-mm-dd格式化日期转换为“长日期”格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有yyyy-mm-dd格式的日期。它被发现是ISO日期格式。我需要将其转换为长日期格式。



例如:我的日期为2015-07-15。转换日期格式应在2015年7月15日。



我通过了几种方法。但没有得到预期的结果。请帮助我找到一个解决方案。

解决方案

我会使用 Moment.js 库为此目的:



  console.log(moment(2015-07-15)。format(DD MMMM YYYY)); // print 2015年7月15日 

 < script src = http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.2.1/moment.min.js>< / script>  


I have date in yyyy-mm-dd format. It is found to be ISO Date format. I need to convert it to Long Date format.

eg: I have date as '2015-07-15'. The converted date format should be in 15 July 2015.

I went through several methods. But didn't get the expected result. Please help me to find a solution.

解决方案

I'd use the Moment.js library for this purpose:

console.log(moment("2015-07-15").format("DD MMMM YYYY")); //prints 15 July 2015

<script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.2.1/moment.min.js"></script>

这篇关于如何使用jquery将yyyy-mm-dd格式化日期转换为“长日期”格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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