Created
June 9, 2019 17:35
-
-
Save Sadicko/bafbacd69d3efc57692b5a5fd770db9c to your computer and use it in GitHub Desktop.
How to format a date using jquery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.date = function(dateObject) { | |
var d = new Date(dateObject); | |
var day = d.getDate(); | |
var month = d.getMonth() + 1; | |
var year = d.getFullYear(); | |
if (day < 10) { | |
day = "0" + day; | |
} | |
if (month < 10) { | |
month = "0" + month; | |
} | |
var date = day + "/" + month + "/" + year; | |
return date; | |
}; | |
Output: dd/mm/yyyy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment