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

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

Jump to Post

He's asked a similar question in another thread: http://www.daniweb.com/web-development/php/threads/451849/check-if-time-falls-within-a-range

where date() was discussed. Hope it saves duplication.

Jump to Post

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

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

Show your code, what happens after the query.

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 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.