Hi, I have inserted time in Database using CURRENT_TIME() and Data type is Time. Now I want to show the Time in AM and PM format. Please guide me.
Thanks in advance....
ayesha789
7
Posting Pro in Training
Recommended Answers
Jump to Postis this a mysql database?
check this point in the manual:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format
(other databases have similar commands)
I find it best to get the data right when selecting it, so use something like
Jump to PostSkipping the code that has no relevance to your problem:
$date = new DateTime(); // this will be a database request echo date_format($date, 'g:i a');
responds with:
9:34 am
(I've added the minutes.)
Personally, i wouldn't use$form=<<<POST
This makes your …
Jump to Post$date = new DateTime(); // this will be a database request $rowDate = date_format($date, 'g:i a'); $form=<<<POST $rowDate POST; echo $form;
outputs:
10:21 am
All 11 Replies
mick_sp
0
Newbie Poster
ayesha789
7
Posting Pro in Training
mick_sp
0
Newbie Poster
ayesha789
7
Posting Pro in Training
mick_sp
0
Newbie Poster
ayesha789
7
Posting Pro in Training
mick_sp
0
Newbie Poster
ayesha789
7
Posting Pro in Training
mick_sp
0
Newbie Poster
ayesha789
7
Posting Pro in Training
mick_sp
0
Newbie Poster
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.