This is how you can change hours without if statement:
hours = ((hours + 11) % 12 + 1);
More Related Contents:
- What are valid Date Time Strings in JavaScript?
- How do you display JavaScript datetime in 12 hour AM/PM format?
- Parsing ISO 8601 date in Javascript
- How to parse a time into a Date object from user input in JavaScript?
- Convert time interval given in seconds into more human readable form
- Javascript timestamp to relative time
- Best JavaScript Date Parser & Formatter? [closed]
- Does anyone know of a good JSON time server?
- Date is in string format
- How do you get a timestamp in JavaScript?
- Format JavaScript date as yyyy-mm-dd
- Incrementing a date in JavaScript
- Javascript – get array of dates between 2 dates
- Converting milliseconds to a date (jQuery/JavaScript)
- Format a number as 2.5K if a thousand or more, otherwise 900
- How to get the difference of two dates in mm-dd-hh format in Javascript
- exclude weekends in javascript date calculation
- Regular Expression | Leap Years and More
- Age from Date of Birth using JQuery
- Is there any way to get current time in nanoseconds using JavaScript?
- How to format numbers as currency strings
- How to change date format in JavaScript [duplicate]
- Work with a time span in Javascript
- Calculate the UTC offset given a TimeZone string in JavaScript
- JS check for valid date format
- If javascript “(new Date()).getTime()” is run from 2 different Timezones
- Javascript: Easier way to format numbers? [closed]
- how to update time regularly?
- Get today date in Google Apps Script
- Maximum Call Stack Size Exceeded During a setTimeout Call