Reputation: 1848
I want to parse date through moment.js (which is normally really easy) but my date contains the abreviation of the timezone, and the symbol zz
do not work here. (moment.js format)
const str1 = "2020-08-28 13:15 CST";
const date1 = moment(str1, "YYYY-MM-DD HH:mm zz");
console.log(date1);
<script src="https://momentjs.com/downloads/moment.min.js"></script>
<script src="https://momentjs.com/downloads/moment-with-locales.min.js"></script>
<script src="https://momentjs.com/downloads/moment-timezone-with-data.js"></script>
As I am currently in UTC+2 timezone, it displays 2020-08-28T11:15:00.000Z
which corresponds to 2020-08-28 13:15:00 UTC+2
.
How could it recognize timezone abreviation ?
Upvotes: 0
Views: 402
Reputation: 794
Use like this
moment.utc('2020-08-28 13:15 CST').format('YYYY-MM-DD HH:mm ZZ')
Upvotes: 1