Get UTC GMT Time using JavaScript
To get Universal Time (UTC) or Greenwich Mean Time (GMT) timestamp using javascript we need to use toUTCString() function on Date variable.
<!DOCTYPE html>
<html>
<head>
<script>
function getUTC() {
//Get timestamp in locale
var tDate = new Date();
//Convert timestamp in GMT/UTC format
var utcDate = tDate.toUTCString();
document.getElementById("utc").innerHTML = utcDate;
console.log(utcDate);
}
</script>
</head>
<body onload="getUTC()">
<div id="utc"></div>
</body>
</html>
⚠️ Note: There is no difference between GMT and UTC time.
More Posts related to JavaScript,
- How to get UTC (GMT) time using JavaScript
- Submit html form on dropdown menu value selection or change using javascript
- How to detect Browser and Operating System Name and Version using JavaScript
- JavaScript : Get current page address
- [javaScript] Convert text case to lowercase
- How to check if a String contains substring or a word using javaScript
- Writing your first Hello, World! 🌍 JavaScript code Tutorial
- JavaScript: Check if variable is a number
- How to send email from JavaScript HTML using mailto
- Meaning of javascript:void(0) explained with example
- How to get query string in JavaScript HTML location.search
- Javascript convert text case from uppercase to lowercase
- Loading previous page using html button using JavaScript
- JavaScript : Get url protocol HTTP, HTTPS, FILE or FTP
- How to get current URL Location using Javascript HTML
- Detect if Cookies are enabled using JavaScript
- Write javaScript code in Swedish using FikaScript
- Add Animated Scrolling to Html Page Title Script
- JavaScript: Convert an Image into Base64 String
- Remove items from JavaScript array
- Send Extra Data with Ajax Get or Post Request
- How to Print from JavaScript HTML using window.print
- Get Device Screen Width and Height using javaScript
- Examples: Convert String to int in JavaScript
- npm WARN saveError ENOENT: no such file or directory, open /mnt/c/package.json
More Posts:
- [fix] Microsoft Error Code 0x80004005 - Unspecified error - Microsoft
- Check version of pip package installer for Python - Python
- [Solution] AWS Java SDK S3 AmazonS3Exception InvalidAccessKeyId - AWS
- Align html element at the center of page vertically and horizontally - Html
- How to connect to SFTP location using Terminal command - FTP
- 11 Weeks of Android Online Sessions-15-Jun-to-28-Aug-2020 - Android
- Error : Facebook SDK AndroidRuntime?FATAL EXCEPTION: main - Android
- Bash For Loop Example - Bash