var someDate = new Date(dateString);
someDate = someDate.getTime();
Answer from CrayonViolent on Stack Overflow
๐ŸŒ
Esqsoft
esqsoft.com โ€บ javascript_examples โ€บ date-to-epoch
Date/Epoch Time Converter - Javascript tools - Learning examples
By making signup date a variable, ... * 3))) { /* ...then this site was signed up more than 3 days ago show them the relevant message */ } 1 Millisecond = 1/1000 in Epoch (used frequently with JavaScript conversions) 1 Second = 1 in Epoch 1 Minute = 60 in Epoch 10 Minutes = ...
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Date
Date - JavaScript - MDN Web Docs - Mozilla
A JavaScript date is fundamentally specified as the time in milliseconds that has elapsed since the epoch, which is defined as the midnight at the beginning of January 1, 1970, UTC (equivalent to the UNIX epoch).
๐ŸŒ
Epoch Converter
epochconverter.com โ€บ epoch converter โ€บ epoch converter functions and routines
Epoch Converter Functions and Routines
SELECT (CAST(SYS_EXTRACT_UTC(SYSTIMESTAMP) AS DATE) - TO_DATE('01/01/1970','DD/MM/YYYY')) * 24 * 60 * 60 FROM DUAL; ... Replace 1526357743 with epoch.
๐ŸŒ
Dana Woodman
danawoodman.com โ€บ writing โ€บ javascript-date-unix-epoc-timestamp
How to convert a JavaScript date to a Unix timestamp (epoch)?
January 31, 2022 - To convert a Unix Timestamp back to a JavaScript date, just multiply it by 1000 to get the number of milliseconds and then pass it to new Date(...): const seconds = 1577865600; const date = new Date(seconds * 1000); A common time format in the world of computer programming is the Unix Timestamp ...
๐ŸŒ
DEV Community
dev.to โ€บ iamephraim โ€บ how-to-convert-epoch-timestamp-to-date-using-javascript-352f
How to Convert Epoch Timestamp to Date Using JavaScript - DEV Community
March 24, 2022 - Being a relatively new language that ushered in the use of time in seconds, Solidity provides a global feature called block.timestamp. In this short piece, I explain how you can convert epoch timestamp emitted from your backend solidity contracts into appropriate date that includes day, month, year and time.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-to-convert-epoch-date-to-meaningful-javascript-date
How to convert epoch Date to meaningful JavaScript date?
August 17, 2022 - <html> <head> </head> <body> <h2>Converting epoch date to meaningful JavaScript date.</h2> <h4>Convert milliseconds since epoch to JavaScript Date using the <i>various methods Date class.</i></h4> <p id = "output1"></p> <script> let output1 = document.getElementById("output1"); let milliseconds = 1348755654324; let myDate = new Date(milliseconds); let dateStr = myDate.getFullYear() + "/" + (myDate.getMonth() + 1) + "/" + myDate.getDate() + " " + myDate.getHours() + ":" + myDate.getMinutes() + ":" + myDate.getSeconds() output1.innerHTML += "date string for " + milliseconds + " milliseconds is : " + dateStr + " <br/> "; </script> </body> </html>
Find elsewhere
๐ŸŒ
Epoch Converter
epochconverter.com
Epoch Converter - Unix Timestamp Converter
JavaScript does not support leap seconds. ... Epoch converter Batch converter Time zone converter Timestamp list LDAP converter .NET DateTime ticks GPS time converter Julian Day converter Chrome/WebKit timestamp Unix hex timestamp Cocoa Core Data timestamp Mac HFS+ timestamp NTP timestamp FAT timestamp SAS timestamp Excel OADate timestamp Seconds/days since year 0 Bin/Oct/Hex converter Year 2038 problem Countdown in seconds Epoch clock
๐ŸŒ
Epochconvert
epochconvert.com โ€บ programming โ€บ javascript
Date Time Conversion in JavaScript - Epoch Converter
We can pass human readable formats ... July 2019 13:30:00 GMT+05:30"); We can get current epoch or unix timestamp in JavaScript using Date() objects and getDate() function....
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Date โ€บ now
Date.now() - JavaScript - MDN Web Docs - Mozilla
The Date.now() static method returns the number of milliseconds elapsed since the epoch, which is defined as the midnight at the beginning of January 1, 1970, UTC. // This example takes 2 seconds to run const start = Date.now(); console.log("starting timer..."); // Expected output: "starting ...
๐ŸŒ
GitHub
github.com โ€บ chocolatetoothpaste โ€บ epoch
GitHub - chocolatetoothpaste/epoch: epoch.js - Awesome date formatting and calculating for JavaScript
date.from('2012-12-08'); // 1 year ago date.from('2019-12-08'); // in 6 years date.from('2013-12-08 12:34:48'); // less than a minute ago ยท epoch.leapYear() or epoch.leap() --- true/false if year is leap year
Author ย  chocolatetoothpaste
Top answer
1 of 2
12

@Parth Trivedi i made two function for you.

$(document).ready(function () {
    alert("Date to Epoch:" + Epoch(new Date()));
    alert("Epoch to Date:" + EpochToDate(Epoch(new Date())));
});

//Epoch
function Epoch(date) {
    return Math.round(new Date(date).getTime() / 1000.0);
}

//Epoch To Date
function EpochToDate(epoch) {
    if (epoch < 10000000000)
        epoch *= 1000; // convert to milliseconds (Epoch is usually expressed in seconds, but Javascript uses Milliseconds)
    var epoch = epoch + (new Date().getTimezoneOffset() * -1); //for timeZone        
    return new Date(epoch);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

2 of 2
0
const epochToDateHuman = ({epochTime=0})=>{
const valueConvert = 60000 // Base convert to Minutes to milliseconds
const milliseconds = 1000 
const zone = (new Date().getTimezoneOffset() * -1 ) * valueConvert  //  Return subtract time zone 
const newEpoch = epochTime * milliseconds  // Convert new value in milliseconds

const dateConvert = new Date(newEpoch + zone) // New Date + Zone 
return dateConvert}



const epoch = 1619456956
epochToDateHuman({epoch})

This arrow function epochToDateHuman, receives as parameters named epochTime that you want to convert to a zone date, The const valueConvert is the basis for converting the zone obtained in minutes to Milliseconds, because Date (). getTimezoneOffset () returns your zone time difference in minutes and when we receive in epochTime we convert them to milliseconds multiplying by the constant milliseconds, like this we obtain newEpoch with a new value in milliseconds and zone in negative milliseconds that will be subtracted from newEpoch that passed to a new Date, we obtain the value for the zone of the date... Happy hacking

Zellathor!

๐ŸŒ
Futurestud.io
futurestud.io โ€บ tutorials โ€บ get-number-of-seconds-since-epoch-in-javascript
Get Number of Seconds Since Epoch in JavaScript
April 4, 2019 - The Date.now() and new Date().getTime() calls retrieve the milliseconds since the UTC epoch. Convert the milliseconds since epoch to seconds by dividing by 1000. This may create a decimal and you have to ensure an integer value by rounding to the next whole number.
๐ŸŒ
Epoch
epoch101.com โ€บ Javascript
Javascript Epoch and DateTime | Epoch101.com
2019-02-16T04:19:44.909Z Year: 2019 Month: 1 Date: 16 Hour: 4 Minutes: 19 Seconds: 44 1995-12-17T03:24:00.000Z ยท var epoch = 1549505686; var date = new Date(epoch * 1000); console.log(date);
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ how-to-get-seconds-since-epoch-in-javascript
How to get seconds since epoch in JavaScript? - GeeksforGeeks
July 12, 2025 - Input: Date = 27-04-2020, 11:55:55 Output: Seconds since epoch - 1587968755 Syntax: new Date(year, month, day, hours, minutes, seconds, milliseconds) Example: ... <script type="text/javascript"> function seconds_since_epoch(d){ return Math.floor( d / 1000 ); } // Driver Code var d = new Date(2020, 4, 29, 22, 00, 00, 00); var sec = seconds_since_epoch(d); document.write("Date " + d + " has " + sec+ " seconds till epoch."); </script> Output:
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-can-i-get-time-and-date-since-epoch-in-javascript
How can I get time and date since epoch in JavaScript?
August 17, 2022 - In the example below, we have created the object of the Date() class to get the date since the epoch. We are also finding the total number of milliseconds since the epoch by dividing the date by 1. Users can also get seconds, minutes, and hours since the epoch. <html> <head> </head> <body> <h2> Get date and time since Unix epochs started in JavaScript.
๐ŸŒ
Zipy
zipy.ai โ€บ blog โ€บ convert-unix-timestamp-to-date-and-time-in-javascript
convert unix timestamp to date and time in javascript
April 12, 2024 - Before diving into conversions, let's briefly touch on what Unix timestamps are and why they're used. A Unix timestamp is a long integer representing the time as the number of seconds since the Unix Epoch (January 1, ...
๐ŸŒ
Coderwall
coderwall.com โ€บ p โ€บ rbfl6g โ€บ how-to-get-the-correct-unix-timestamp-from-any-date-in-javascript
How to get the correct Unix Timestamp from any Date in JavaScript (Example)
June 26, 2023 - Copy & paste the following code ... Date.prototype.getUnixTime = function() { return this.getTime()/1000|0 }; if(!Date.now) Date.now = function() { return new Date(); } Date.time = function() { return Date.now().getUnixTime(); } ... ...