Skip to content

Instantly share code, notes, and snippets.

@vldvel
Last active February 24, 2018 19:15
Show Gist options
  • Save vldvel/5586de6f84922ce96b102e246bdb03fa to your computer and use it in GitHub Desktop.
Save vldvel/5586de6f84922ce96b102e246bdb03fa to your computer and use it in GitHub Desktop.
// PM case
if (arr[0] == 12) { // as 12 is the string I use ==, but you can rewrite it like === '12'
arr[0] = '12';
} else {
arr[0] = Number(arr[0]) + 12; // if we add number to string we will get new string like '1312'
}
// AM case
if (arr[0] == 12) {
arr[0] = '00';
}
// In other cases AM is the same as 24h format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment