10 examples of 'javascript convert epoch to date' in JavaScript

Every line of 'javascript convert epoch to date' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
149export function convertEpochToDate(epoch: number): Date{
150 const d = new Date(0)
151 d.setUTCSeconds(epoch)
152 return d
153}
11function asEpochS(date) {
12 return Math.round(date.getTime() / 1000);
13}
39function getEpochTimeDatestamp(t) {
40 var date = new Date(t * 1000);
41 var s = date.getFullYear();
42 s += "-";
43 var monthNum = date.getMonth() + 1;
44 if (monthNum < 10) {
45 s += "0";
46 }
47 s += monthNum;
48 s += "-";
49 if (date.getDate() < 10) {
50 s += "0";
51 }
52 s += date.getDate();
53 return s;
54}
107function epoch() {
108 return Math.floor(new Date().getTime()/1000);
109}
5export function dateUTCToLocal( date )
6{
7 return new Date( date.getTime( ) + TimeZoneOffset );
8}
25function dateToJulianDate(date) { return date.valueOf() / dayMS - 0.5 + J1970; }
416getEpochTime() {
417 return Math.round((new Date).getTime() / 1000);
418}
182function Date_Time(julian_date) {
183 return new Date((julian_date - 2440587.5) * 86400000.);
184}
21export function dateToUTC(timestamp) {
22 const date = new Date(timestamp * 1000);
23 return new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(),
24 date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
25}
26function JulianDate(jsDate) {
27 var jET;
28 with(jsDate)
29 swisseph.swe_utc_time_zone (
30 getFullYear(),
31 getMonth() + 1,
32 getDate(),
33 getHours(),
34 getMinutes(),
35 getSeconds() + getMilliseconds() / 1000,
36 tzone,
37 function (result) {jET = result;}
38 );
39 with(jET)
40 swisseph.swe_utc_to_jd (
41 year,
42 month,
43 day,
44 hour,
45 minute,
46 second,
47 swisseph.SE_GREG_CAL,
48 function (result) {
49 assert (!result.error, result.error);
50 jET = result.julianDayET;
51 });
52 return jET;
53};

Related snippets