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,
- Add Animated Scrolling to Html Page Title Script
- How to get query string in JavaScript HTML location.search
- How to get current URL Location using Javascript HTML
- How to detect Browser and Operating System Name and Version using JavaScript
- Submit html form on dropdown menu value selection or change using javascript
- How to Print from JavaScript HTML using window.print
- JavaScript : Get url protocol HTTP, HTTPS, FILE or FTP
- JavaScript : Get current page address
- How to send email from JavaScript HTML using mailto
- Send Extra Data with Ajax Get or Post Request
- Write javaScript code in Swedish using FikaScript
- Get Device Screen Width and Height using javaScript
- How to get UTC (GMT) using javascript
- Javascript convert text case from uppercase to lowercase
- Loading previous page using html button using JavaScript
- [javaScript] Convert text case to lowercase
- Detect if Cookies are enabled using JavaScript
More Posts:
- SharePoint Server 2016 IT Preview Deprecated Removed features - SharePoint
- How to make jsfiddle bootstrap ready - CSS
- How to enable line numbers in Eclipse - Eclipse
- Parsing Data for android-21 failed unsupported major.minor version 51.0 - Android
- SDK Manager: failed to install : Android Studio on Windows - Android-Studio
- Remove ActionBar from Activity that extends appcompat-v7 - Android
- Loading previous page using html button using JavaScript - JavaScript
- Tutorial : Simple Lightweight Pure CSS based Vertical Navigation Menu - CSS
- Calculate Area and Circumference of Circle - C-Program
- Gmail Error Bad Request Your client has issued a malformed or illegal request - Google
- How to Apply Themes to Notepad++ - NotepadPlusPlus
- [Solved] SharePoint Access Denied error editing Document Name - SharePoint
- Calculate Volume of Cube - C-Program
- The service instance "Microsoft SharePoint Insights" could not be provisioned because of the following error: Authentication information for SPInsights service has not been set yet - SharePoint
- Use Netbeans keyboard shortcuts in Android Studio - Android-Studio