Hello all.. I have written a query that returns dateTime field of mysql in the following format:
YYYY-MM-DD HH:MM:SS (Eg. 2008-10-31 16:40:00)...
I want to display this as (2008-10-31 4:40:00 PM)...
Can anyone tell me how to do this??
Thanks in advance
changing the format of date
Moderator: General Moderators
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: changing the format of date
Code: Select all
$yourDate=date("Y-m-d G:i:sA");Re: changing the format of date
I think i didnt make myself clear..
The sql query returns me a string with the format as 2008-10-31 16:40:00 which happens to be taken as string in the query..
is there any way i can convert from $sql_time to $my_reqd_format??
Think i am clearer this time..
The sql query returns me a string with the format as 2008-10-31 16:40:00 which happens to be taken as string in the query..
Code: Select all
$sql_time = "2008-10-31 16:40:00";
$my_reqd_format = "2008-10-31 4:40 PM";
Think i am clearer this time..
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: changing the format of date
Ok, so what you need to do is the following:
Code: Select all
$my_reqd_format=date("Y-m-d G:iA", strtotime($sql_time));
Re: changing the format of date
yaa now i got it.. thanx a tonn.. and its 'h' for the 12 hour format.. thanks alot anyway