我正在尝试将Time String解析为矩对象,因为AM字符串“ 09:00 am”工作得很好,但是对于PM字符串“ 06:00 pm”则不行。
使用此代码:
moment.tz.setDefault('Asia/Jerusalem');
moment.locale('he')
const momentObject1 = moment("09:00 am", "HH:mm a");
const momentObject2 = moment("06:00 pm", "HH:mm a");
我在做什么错了?
答案 0 :(得分:0)
似乎正在工作:
moment.tz.setDefault('Asia/Jerusalem');
moment.locale('he')
console.log(moment("06:00 am", "hh:mm a").format())
console.log(moment("06:00 pm", "hh:mm a").format())
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.25/moment-timezone-with-data.min.js"></script>