I have a date on Wed Dec 25 2019 05:30:00 GMT+0530
. I want to format into 25 Dec
How can I do that?
const date= currentItem.date;
First convert it into moment
let date_moment=moment(currentItem.date,"ddd MMM DD YYYY HH:mm:ss ZZ")
Then convert it to required format
let req_format=date_moment.format("DD MMM")
Note: if your timeformat is 12 hour use hh. for other datetime format and timezone format check moment documentation:) Moment Docs
This snippet of code will get exactly what you want from any date entered as variable name date
to dateIn
.
var dateIn = moment(date, 'YYYY/MM/DD');
var month = dateIn.format('M');
var day = dateIn.format('D');
console.log(day + " " + month);
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.