Page 1 of 1

time()

Posted: Tue Feb 25, 2003 1:15 am
by Mr. Tech
I have a article manager and when you submit an article and it enters it into the MySQL DB I use the time() function.

How do I convert time() from the db to something like 2/3/2003?

Thanks

Posted: Tue Feb 25, 2003 2:06 am
by jiop

Posted: Tue Feb 25, 2003 6:20 pm
by Mr. Tech
Thanks but the link you gave me doesn't really help.. What code would I need to convert time() into date()?

Thanks for your help!

Posted: Wed Feb 26, 2003 2:40 am
by twigletmac
time() produces a UNIX timestamp, date() takes two arguments: the date formatting options and a timestamp.

Mac

Posted: Wed Feb 26, 2003 5:02 pm
by Mr. Tech
So in phpMyAdmin I need to change uptime to the timestamp command thing? And that will show the date?

Posted: Wed Feb 26, 2003 7:23 pm
by McGruff
I use an integer column to store time() timestamps mainly because I'm too lazy to learn all the mysql date/timestamp stuff (a mysql timestamp can update itself though: could be useful or could be a problem - see manual).

Is that what you were looking for?

Posted: Thu Feb 27, 2003 3:49 am
by twigletmac
Mr. Tech wrote:So in phpMyAdmin I need to change uptime to the timestamp command thing? And that will show the date?
Erm, no if you've got your time() result stored in the database you can just do:

Code: Select all

$formatted_date = date('d/m/Y', $timestamp_from_database);
time() returns a UNIX timestamp so it's fine to use that in the date() function.

Mac

Posted: Thu Feb 27, 2003 5:02 pm
by Mr. Tech
Thanks! I'll give it a try

Posted: Thu Feb 27, 2003 5:08 pm
by Mr. Tech
YAY! Work! THANKS!