Skip to content

Instantly share code, notes, and snippets.

@shrutis22
Last active July 27, 2016 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shrutis22/fba18ab76bdf522736fca33d7d9f464f to your computer and use it in GitHub Desktop.
Save shrutis22/fba18ab76bdf522736fca33d7d9f464f to your computer and use it in GitHub Desktop.
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