Get Current time in GMT/UTC using JavaScript


Make use of the toUTCString() method from the Date() constructor to get the current UTC time and date in JavaScript.


Example 1: Current Date and Time in UTC

    const date = new Date();
    const utcDateString = date.toUTCString();
    console.log("Current GMT Date Time: " + utcDateString);
    Output:

    Current GMT Date Time: Fri, 08 Sep 2023 12:23:04 GMT


Example 2: Current Time in GMT

    const date = new Date();
    const utcTimeString = date.toUTCString().split(" ")[4];
    console.log("Current GMT Time: " + utcTimeString);
    Output:

    Current GMT Time: 12:25:59


Example 3: Current Date in GMT

    const date = new Date();
    const utcDateString = date.toUTCString().split(" ").slice(1, 4).join(" ");
    console.log("Current GMT Date: " + utcDateString);
    Output:

    Current GMT Date: 08 Sep 2023


What is UTC Timezone?



UTC (Coordinated Universal Time) is a stable Global Time Standard, which does not observe Daylight Saving Time (DST) and is often used as a reference for precise timekeeping in JavaScript and various applications.


We can also make use of the toISOString() to get the time now in UTC/GMT.

Example 4: Date and Time in Zulu (Z/UTC/GMT)

    const dateZulu = new Date().toISOString();
    console.log("Date Time in Zulu Now: " + dateZulu);
    Output:

    Date Time in Zulu Now: 2023-09-08T13:11:29.142Z


JSFiddle Link: https://jsfiddle.net/r0b79zdh/

What is the difference between GMT/UTC/Zulu

GMT stands for - "Greenwich Mean Time" and is usually interchangeable with UTC - "Coordinated Universal Time", they both being stable Global Time Standards. "Zulu" is a military term referring to UTC, primarily in aviation.

JavaScript Current Date and Time in UTC GMT and Zulu Examples

This is not an AI-generated article but is demonstrated by a human on an M1 Mac running macOS Sonoma 14.0.

Please support independent contributors like Code2care by donating a coffee.

Buy me a coffee!

Buy Code2care a Coffee!

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap