Skip to content

Instantly share code, notes, and snippets.

@shrutis22
Last active Jul 27, 2016
Embed
What would you like to do?
Convert a date to system locale date.
var formatDate = function() {
moment.locale( window.navigator.userLanguage || window.navigator.language );
$( "[data-type='date']" ).each(
function() {
var currentDate = $( this ).html();
if( currentDate !== '' ) {
var formatedDate = moment( currentDate ).format( 'L' );
$( this ).html( formatedDate );
}
}
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment