I am generating time with a sql script

$query = "select current_timestamp as time";

When my system time is in 24 hrs format it returns a 24 hr format time. but when it is 12 hrs format it returns a 12 hr format time.

But I want my time to be in 24 hrs format.
Please any one have a technique that I can use to always generate time in 24 hrs format.
Or any convertion and detection script that would help me generate a 12 hr format and convert it to 24 hr format.

Recommended Answers

All 6 Replies

The query should return it as 24 hours format (according to the manual). What do you do with the result of the query?

yeah it does returns 24 hr format when my system time is in 24 hrs format.

But if it is 12 hrs format I get a 12 hr format time.

It kind of confusing for me cos my app really needs time in 24hr format.

Member Avatar for diafol

You can decide on the format - you shouldn't be a slave to your server / PC settings.

date("H:i:s") will give the date in 24 hour format.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.