PHP Function to Convert 12 Hour Time to 24 Hour Format

/ Published in: PHP
Save to your folder(s)

Convert 12-hour time format with hour, minutes, seconds, and meridiem into 24-hour format. Performs data correction to make sure hours, minutes and seconds have leading zeros if needed.

The trick here is to use strtotime() where we pass the time string in this format: "hh:mm:ss meridiem"
Example: "02:30:00 pm"

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.