Skip to content

Instantly share code, notes, and snippets.

@fsojitra
Created March 17, 2018 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fsojitra/c96ec6eb74eb1e476be1dc47c4e92f0c to your computer and use it in GitHub Desktop.
Save fsojitra/c96ec6eb74eb1e476be1dc47c4e92f0c to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.3/moment.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
setInterval(function(){
var divUtc = $('#divUTC');
var divLocal = $('#divLocal');
utc = moment.utc().format('YYYY-MM-DD HH:mm:ss');
console.log('utc'+moment.utc().toDate());
divUtc.text(utc);
var localTime = moment.utc().toDate();
console.log('localTime'+localTime);
localTime = moment(localTime).format('YYYY-MM-DD HH:mm:ss');
divLocal.text(localTime);
},1000);
});
</script>
</head>
<body>
UTC<br/>
<div id="divUTC"></div><br/>
Your Local Time with respect to above UTC time<br/>
<div id="divLocal">
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment