I have a date:
let date = "15:00";
and I want to process it to format: 2019-09-26T15:00:00.000Z
, but momentjs get and invalid date error.
I tried using moment(date).format('LTS');
let date = "15:00"
let m = moment(date, "HH:mm");
m.utc().format();
Note: This will use current date's date as default since you're only passing the time.
You should add the format of value also, like this:
let date = "15:00";
let m = moment(date, 'HH:mm').toISOString();
console.log(m);
Because you need something like this 2019-09-26T15:00:00.000Z
, it's better to use the toISOString
function, rather than the format
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.