Hi there, I have the following:
2006-04-16 11:38:36
(produced from the now() function)
What I want to be able to do is convert that to user friendly information e.g. 11.38 Sunday 16th April, is there an easy way to do this short of ripping the string apart and writing repetetive if statements to find out what each peice is, eg. 04 = "April" etc..
The data is already ammassed in a database and so changing how it is stored is not an option, hence i need to manipulate it with PHP.
Thanks,, Tom
now() to string?
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Why can't you convert your database to a more generic format? A couples lines of code could get it done..
short of that, try passing your date into strtotime() (php) which will returns a timestamp and pass that to date() (php).. you may be able to convert your date into a timestamp via UNIX_TIMESTAMP (mysql) during the selection, although I'm not sure..
short of that, try passing your date into strtotime() (php) which will returns a timestamp and pass that to date() (php).. you may be able to convert your date into a timestamp via UNIX_TIMESTAMP (mysql) during the selection, although I'm not sure..
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
You'll need to convert the data to a unix timestamp before using date()
UNIX_TIMESTAMP() .. You could also use DATE_FORMAT()
UNIX_TIMESTAMP() .. You could also use DATE_FORMAT()