Current Unix Timestamp SECONDS SINCE JAN 01 1970

Current UTC Time
2025-04-26
Convert Unix Timestamp to Datetime in JavaScript

How to convert Unix timestamp to Datetime in JavaScript

🎈 🎈 🎈
+1

    const unixTimestamp = 1693088296;
    const date = new Date(unixTimestamp * 1000);
    console.log("Converted Date: " + date.toLocaleString());            
        

Output:
Converted Date: 2023-08-26 22:18:16
Example only. There may be multiple ways to perform this operation.

Code Explanation

In this JavaScript example, the Unix timestamp (1693088296) is first multiplied by 1000 to convert it to milliseconds, as JavaScript's Date object expects the time in milliseconds.
The Date object then creates a date instance representing that specific point in time. Finally, the toLocaleString() method is used to convert the date into a human-readable string format based on the local time zone.


Other useful JavaScript date functions

Function Description Example
Date() Creates a new date object representing the current date and time. new Date() returns Wed Aug 28 2024 12:34:56 GMT+0000 (Coordinated Universal Time)
Date.now() Returns the number of milliseconds elapsed since January 1, 1970, 00:00:00 UTC. Date.now() returns 1693227296789
Date.parse() Parses a date string and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC. Date.parse("2024-08-28T12:34:56Z") returns 1727420096000
getFullYear() Returns the year of the specified date according to local time. new Date().getFullYear() returns 2024
getMonth() Returns the month (0-11) of the specified date according to local time. new Date().getMonth() returns 7 for August (0-indexed)
getDate() Returns the day of the month (1-31) for the specified date according to local time. new Date().getDate() returns 28
getDay() Returns the day of the week (0-6) for the specified date according to local time. new Date().getDay() returns 3 for Wednesday (0 = Sunday)
getHours() Returns the hour (0-23) of the specified date according to local time. new Date().getHours() returns 12
getMinutes() Returns the minutes (0-59) of the specified date according to local time. new Date().getMinutes() returns 34
getSeconds() Returns the seconds (0-59) of the specified date according to local time. new Date().getSeconds() returns 56
getTime() Returns the number of milliseconds since January 1, 1970, 00:00:00 UTC for the specified date. new Date().getTime() returns 1693227296789
toISOString() Returns the date as a string in ISO format (YYYY-MM-DDTHH:mm:ss.sssZ). new Date().toISOString() returns 2024-08-28T12:34:56.789Z
toLocaleDateString() Returns the date portion of a Date object as a string, using locale conventions. new Date().toLocaleDateString() returns 08/28/2024 in the US format
toLocaleTimeString() Returns the time portion of a Date object as a string, using locale conventions. new Date().toLocaleTimeString() returns 12:34:56 PM
Current Unix Timestamp SECONDS SINCE JAN 01 1970

Current UTC Time
2025-04-26
Ad Banner Placeholder
Ad Banner Placeholder
Ad Banner Placeholder
Ad Banner Placeholder