Skip to content

Instantly share code, notes, and snippets.

@nishantrpai
Last active May 7, 2021 05:34
Show Gist options
  • Select an option

  • Save nishantrpai/a69cd8eb4f010e26b7b6be6ebf08b706 to your computer and use it in GitHub Desktop.

Select an option

Save nishantrpai/a69cd8eb4f010e26b7b6be6ebf08b706 to your computer and use it in GitHub Desktop.
// For time series data
let d = new Date();
let ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d);
let mo = new Intl.DateTimeFormat('en', { month: 'short' }).format(d);
let da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d);
let hh = new Intl.DateTimeFormat('en', { hour: 'numeric', hour12: false }).format(d);
let mm = parseInt(new Intl.DateTimeFormat('en', { minute: 'numeric' }).format(d));
mm = mm > 9 ? mm : `0${mm}`
let ss = parseInt(new Intl.DateTimeFormat('en', { second: 'numeric', hour12: false }).format(d));
ss = ss > 9 ? ss : `0${ss}`
console.log(`${mo} ${da} ${ye} ${hh}:${mm}:${ss}`);
@nishantrpai

Copy link
Copy Markdown
Author

Add an alias in bash

alias timenow='node ~/timenow.js | xsel -ib'

Whenever you run timenow in the terminal, it'll be copied automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment