Created
September 1, 2019 04:57
-
-
Save earvinpiamonte/4bfbc3adc0992e7e07fd9773d3a06dbc to your computer and use it in GitHub Desktop.
Display user's local time using PHP (client side)
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
// date time from server side | |
// echo date('Y-m-d H:i:s', time()); | |
// date time from client side | |
echo '<script type="text/javascript"> | |
var d = new Date(); | |
document.write(d.getFullYear()+"-"+("0"+(d.getMonth() + 1)).slice(-2)+"-"+("0"+d.getDate()).slice(-2)+" "+("0"+d.getHours()).slice(-2)+":"+("0"+d.getMinutes()).slice(-2)+":"+("0"+d.getSeconds()).slice(-2)); | |
</script>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment