Page 1 of 1

now() to string?

Posted: Sun Apr 16, 2006 9:37 am
by tommy1987
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

Posted: Sun Apr 16, 2006 9:48 am
by toasty525

Posted: Sun Apr 16, 2006 9:51 am
by John Cartwright
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..

Posted: Sun Apr 16, 2006 9:51 am
by feyd
You'll need to convert the data to a unix timestamp before using date()

UNIX_TIMESTAMP() .. You could also use DATE_FORMAT()