mktimestamp

generates a timestamp from current or provided date/time, utc or local

Usage no npm install needed!

<script type="module">
  import mktimestamp from 'https://cdn.skypack.dev/mktimestamp';
</script>

README

mktimestamp

generates a timestamp from current or provided date/time, utc or local

Why?

Mostly because I need a UTC timestamp, but this package allows conversion of arbitrary timestamps to UTC or, in the simplest case, acts as a configurable proxy to Date.now()

Usage

import { mktimestamp, utcnow, now } from "mktimestamp";

const rightNow = mktimestamp();
const utcNow = mktimestamp({ utc: true });
const utcSomeOtherTime = mktimestamp({ utc: true, timestamp: 1596020185055 });

// alternative invocations
const rightNow2 = mktimestamp("local");
const utcNow2 = mktimestamp("utc");

// convenience functions
const utcNow3 = utcnow();
const rightNow3 = now();

Credits

This project is made easier by: