How to convert (20190909070000+0000) to timespan like mm/dd/yyyy hh:mm:ss pm by using moment.js

huangapple go评论66阅读模式
英文:

How to convert (20190909070000+0000) to timespan like mm/dd/yyyy hh:mm:ss pm by using moment.js

问题

我正在尝试使用 moment.js 将日期时间值 "20190909070000+0000" 转换为 mm/dd/yyyy hh:mm:ss pm 格式。请帮助我。

英文:

I am trying to convert datetime "20190909070000+0000" value into mm/dd/yyyy hh:mm:ss pm by using moment.js.

Kindly assist me on this.

答案1

得分: 0

以下是您要翻译的内容:

const datetime = "20190909070000+0000";
const parsed = moment(datetime, "YYYYMMDDHHmmssZ").format('MM/DD/YYYY hh:mm:ss A');
console.log(parsed);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js"></script>
英文:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-js -->

const datetime = &quot;20190909070000+0000&quot;;
const parsed = moment(datetime, &quot;YYYYMMDDHHmmssZ&quot;).format(&#39;MM/DD/YYYY hh:mm:ss A&#39;);


console.log(parsed);

<!-- language: lang-html -->

&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js&quot;&gt;&lt;/script&gt;

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年4月13日 20:08:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76005245.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定