在JavaScript中转换日期 [英] Converting dates in JavaScript
本文介绍了在JavaScript中转换日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在JavaScript中将一种日期格式转换为另一种格式?
How can I convert one date format to another format in JavaScript?
示例:
格式是
YYYY / MM / DD
YYYY/MM/DD
但是我想把它转换成
DD-MM-YYYY
DD-MM-YYYY
推荐答案
我想您可以使用 jQuery UI 库的 datepicker :使用 parseDate 方法将字符串转换为Date对象,然后 formatDate 转换日期对象到另一个字符串。检查现场提供的样品;它们包括格式修饰符。
I think you can use jQuery UI library's datepicker: use the parseDate method to convert a string to a Date object, and then formatDate to convert the Date object to another string. Check the samples provided on the site; they include format modifiers.
这篇关于在JavaScript中转换日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文