Last active
February 5, 2018 13:28
-
-
Save danielnaranjo/664715e72bd420afed32b998e5276046 to your computer and use it in GitHub Desktop.
Reformat Simple date.
This file contains 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
// As you know how's date is coming | |
// You do not need to validate or do something else.. | |
// Example: 2018-02-05 12:00 but you date to be displayed need to be: dd/mm/yyyy | |
// Display into HTML tag like <div id="demo"></div> | |
// document.getElementById("demo").innerHTML = reformat('2018-02-05 12:00'); | |
var reformat = function(input){ | |
var original = input.split(" "); // Split: This one: 2018-02-05 and this one: 12:00 | |
var changed = original[0].split("-") // Now, split it again to: DD/MM/YYYY | |
return changed[2]+'/'+changed[1]+'/'+changed[0]; // Returned! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment