Created
December 15, 2017 13:58
-
-
Save sachinrana95/74065a6336e1df98ea1c591d3257eed6 to your computer and use it in GitHub Desktop.
Get user currect time
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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <title>All Posts</title> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| </head> | |
| <body> | |
| <h1 id="divUTC"><?php date_default_timezone_set('UTC'); echo date("Y-m-d h:i:s"); ?></h1> | |
| </body> | |
| </html> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.19.4/moment.min.js"></script> | |
| <script> | |
| $(document).ready(function() { | |
| // $('#divUTC').each(function(i, v){ | |
| var cell = $('#divUTC'); | |
| var localTime = moment.utc(cell.text()).local().format('YYYY-MM-DD hh:mm:ss'); | |
| cell.text(localTime); | |
| }); | |
| // }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment