Skip to content

Instantly share code, notes, and snippets.

@Blumed
Last active April 12, 2024 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Blumed/24d62a60b6be67efe93185f2be3f2c2a to your computer and use it in GitHub Desktop.
Save Blumed/24d62a60b6be67efe93185f2be3f2c2a to your computer and use it in GitHub Desktop.
Bookmarklet for right now time in this 2024.04.12.15.25 format
/*
Raw Code
*/
try {
const rightNow = new Intl.DateTimeFormat("en-US", {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
hour12: false,
timeZone: "America/Chicago", // <- Edit this string in the script below if you don't live here
});
const dismantle = rightNow.formatToParts(new Date());
const assemble = `${dismantle[4].value}.${dismantle[0].value}.${dismantle[2].value}.${dismantle[6].value}.${dismantle[8].value}`;
navigator.clipboard.writeText(assemble);
console.log('Content copied to clipboard\n' + assemble);
} catch (err) {
console.error('Failed to copy: ', err);
}
/*
Copy the following code and paste it into your url field in a bookmark
*/
javascript:(function(){try{const e=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1,timeZone:"America/Chicago"}).formatToParts(new Date),o=`${e[4].value}.${e[0].value}.${e[2].value}.${e[6].value}.${e[8].value}`;navigator.clipboard.writeText(o),console.log("Content copied to clipboard\n"+o)}catch(e){console.error("Failed to copy: ",e)}}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment