我需要将最初以字符串形式给出的"dd/mm/yyyy“格式的日期转换为有效的date对象,但我遇到了问题。为此,我使用moment.js库,但是当我试图将它转换为date对象时,它在内部不正确地对待它。
最初我有:
var date_text = '02/01/2020 00:10'; //i.e. January 2, 2020.
var initial_date = new Date(date_text); //here js takes its default format and the problem starts.
var a = moment(initi
我有一个日期数组,它在每个日期中都有一个约会时间数组。我循环遍历给定的日期,以获得这样的约会时间:
var newdate = moment(appdate).format('DD/MM/YYYY'); //eg newdate is 04/04/2016
var newtime = moment(apptime).format('h:mm a');
appointmentArr[newdate].forEach(function(value, key) {
console.log(value); //these are all the app