Function like $.datepicker.formatDate for formatting time?
javascript, jquery
Solution
The datepicker's formatDate() method does not have any option to format time, for that look at a datetime library like moment.js
Ex
var date = new Date();
var df = moment(date).format('MMMM Do YYYY, h:mm:ss a');
alert(df)
and
var d = moment('2013-09-11 14:44:03', 'YYYY-MM-DD HH:mm:ss');
console.log(d.format('M/D/YYYY h:m A'))
Demo: Fiddle
Problem
With `$.datepicker.formatDate` I can only format a date, meaning if I pass in a Date object, I can only get the date part of it formatted but not the time part. Is there any equivalent function which allows the time part to also be formatted/parsed, preferably in the same syntax? I'm using the following datetime plugin: https://github.com/eternicode/bootstrap-datepicker But it doesn't seem to have an equivalent formatDate function that I can use.