Skip to content

Instantly share code, notes, and snippets.

@unrealapex
Created March 4, 2022 05:34
Show Gist options
  • Select an option

  • Save unrealapex/1e0fb86b07d977533a82743820468d32 to your computer and use it in GitHub Desktop.

Select an option

Save unrealapex/1e0fb86b07d977533a82743820468d32 to your computer and use it in GitHub Desktop.
var hours = 12;
var suffix = hours <= 12 ? "PM" : "AM";
hours = ((hours + 11) % 12 + 1) + suffix;
console.log(hours);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment