![]() |
|
|
#1 (permalink) |
|
The 4 Eyed Monk.
![]() |
Ok...
I I want to convert date coming from my mysql database i.e 2008-02-01, lets say to date in plane english i.e Feb 2nd, 2008. I have tried all the dateTime functions I could find, but all they do is return the current date for all the entries, even though they are different. What is the solution? Thanks
__________________
|
|
|
|
|
|
#2 (permalink) |
|
Sir Lancelot
Tribunus Militum Consulari Potestate ![]() Join Date: Sep 2001
Location: Germantown, MD
Rep Power: 21474942
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Code:
Code:
__________________
Member: T-CAN, P-WAN, APPN, NGBC, CoHE, CDC No disrespectfulness or bitchassness shall be tolerated.
|
|
|
|
|
|
#3 (permalink) | |
|
The 4 Eyed Monk.
![]() |
Quote:
![]()
__________________
|
|
|
|
|
|
|
#4 (permalink) |
|
Sir Lancelot
Tribunus Militum Consulari Potestate ![]() Join Date: Sep 2001
Location: Germantown, MD
Rep Power: 21474942
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
So heres your function...
Lets say your database stores your date "2008-02-01" in the string $date heres what you do: PHP Code:
__________________
Member: T-CAN, P-WAN, APPN, NGBC, CoHE, CDC No disrespectfulness or bitchassness shall be tolerated.
|
|
|
|
|
|
#5 (permalink) | |
|
The 4 Eyed Monk.
![]() |
Quote:
__________________
|
|
|
|
|
|
|
#7 (permalink) | |
|
Sir Lancelot
Tribunus Militum Consulari Potestate ![]() Join Date: Sep 2001
Location: Germantown, MD
Rep Power: 21474942
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Quote:
First you split (using the "-" as separator), so you get the composite date components in $year, $month, and $day. Then you call mktime() to convert those composites into time. You call date() to format that time into the new format j-M-y. ![]()
__________________
Member: T-CAN, P-WAN, APPN, NGBC, CoHE, CDC No disrespectfulness or bitchassness shall be tolerated.
|
|
|
|
|
|
|
#8 (permalink) |
|
Sir Lancelot
Tribunus Militum Consulari Potestate ![]() Join Date: Sep 2001
Location: Germantown, MD
Rep Power: 21474942
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
PHP Code:
Feb 01, 2008.
__________________
Member: T-CAN, P-WAN, APPN, NGBC, CoHE, CDC No disrespectfulness or bitchassness shall be tolerated.
|
|
|
|
|
|
#10 (permalink) |
|
Captain
![]() Join Date: Jul 2001
Location: Retirement
Rep Power: 21474900
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
PHP is a little complicated as php deals with dates in the UNIXTIMESTAMP form so you have to convert to that before you can format it in php.
I have a couple solutions: Sol 1: Here is are pure mysql solution. If the column datatype is date try this: PHP Code:
2. MySQL has a function to convert any time of timeand date or date datatype column into a unix timestamp for you. Use SELECT * UNIX_TIMESTAMP(your_date_column) FROM `timeanddate` and then use the php date function to convert the date to the desired format. For neatness, i like to use aliases. e.g. PHP Code:
PHP Code:
Give this a shot. It should work. I tried the MySql part. ![]()
__________________
"A small stone may only make a small ripple at first, but someday it will be a wave." -Wiegraf, FFT NR Tribalists, Religious Bigots, and Enemies of Progress: Your name Here? Beat the U.S. Financial Crisis |
|
|
|
|
|
#12 (permalink) |
|
Captain
![]() Join Date: Jul 2001
Location: Retirement
Rep Power: 21474900
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
nice one
__________________
"A small stone may only make a small ripple at first, but someday it will be a wave." -Wiegraf, FFT NR Tribalists, Religious Bigots, and Enemies of Progress: Your name Here? Beat the U.S. Financial Crisis |
|
|
|
|
|
#13 (permalink) |
|
Registered User
Join Date: Dec 2006
Location: On High Grounds
Rep Power: 0
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Bros can u pls help me with either AVG Latest edition or Avast antivirus with the crack. if u can help upload and send to edux2@yahoo.com. i need it badly
__________________
Neva offend Ur Fanz else u end up like :fancy: . if u believe me then u dey Mental.Above all
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|