JSFiddle - React, Tailwind, and code Playground

by codemeasandwich

JavaScript

// get a Date
const now = new Date()

// Get UTC v1
const timeStamp = new Date().getTime()
const offset = now.getTimezoneOffset() * 60 * 1000

// Get UTC v2
const utc = Date.UTC(now.getFullYear(),
                     now.getMonth(),
                     now.getDate(),
                     now.getHours(),
                     now.getMinutes(),
                     now.getSeconds(),
                     now.getMilliseconds());

// OUTPUT
console.log("NOW",new Date(timeStamp),timeStamp)
console.log("UTC",new Date(utc),utc)

console.log( "UTC === (timeStamp-offset) ", utc === timeStamp - offset)