Created
March 17, 2018 10:21
-
-
Save fsojitra/c96ec6eb74eb1e476be1dc47c4e92f0c to your computer and use it in GitHub Desktop.
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
<!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