如何将DateTime转换为另一种格式? [英] How do I convert DateTime to another format?

查看:98
本文介绍了如何将DateTime转换为另一种格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从天气馈送中以 2012-05-17 的形式获取日期数据。

From a weather feed I'm getting the data for dates in the form of 2012-05-17.

如何将其转换为 5月17日星期四表格?

推荐答案


  1. 将字符串解析为JavaScript 日期对象。

  2. 随意设置日期对象的格式。

  1. Parse the string into a JavaScript Date object.
  2. Format the Date object however you like.

另请参见:为什么Date.parse给出不正确的结果?如何格式化JavaScript日期问题。

See also: Why does Date.parse give incorrect results? and How to format a JavaScript date questions.

这篇关于如何将DateTime转换为另一种格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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