I have a date variable like:
var date_value = new Date(
parseInt(date.year()),
parseInt(date.month()) - 1,
parseInt(date.day()));
// date_value = Date 2016-07-24T21:00:00.000Z
I want to format that date into many formats. Is there is any built-in function in JavaScript to format that date into any format I want in the convention of Python Example: (%m%d%Y),(%d%m%Y),("%m/%d/%Y %H:%M:%S")
? I used the $.datepicker.formatDate('mm/dd/yy 00:00:00', date_value)
but it doesn't fit my needs.
There is not built-in functionality to format dates. You need to use an external library like moment.js .
date_value = moment().year(year).month(month).date(day); // or date_value = moment(date); date_value.format("M/D/Y HH:mm:ss");
Use momentjs
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.