Skip to content

Instantly share code, notes, and snippets.

@sachinrana95
Created December 15, 2017 13:58
Show Gist options
  • Select an option

  • Save sachinrana95/74065a6336e1df98ea1c591d3257eed6 to your computer and use it in GitHub Desktop.

Select an option

Save sachinrana95/74065a6336e1df98ea1c591d3257eed6 to your computer and use it in GitHub Desktop.
Get user currect time
<!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