Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <p>This demo used to validate time with 12 hours format</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- function myFunction() {
- var regexp = /^(0?[1-9]|1[012])(:[0-5]\d) [APap][mM]$/;
- var res = regexp.test('12:00 AM'); //try with alphabets or wrong format
- document.getElementById("demo").innerHTML = res;
- }
- </script>
- </body>
- </html>
- $time_in_12_hour_format = date("g:i a", strtotime("13:30"));
- // 12-hour time to 24-hour time
- $time_in_24_hour_format = date("H:i", strtotime("1:30 PM"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement