time()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

time()

Post 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
jiop
Forum Newbie
Posts: 11
Joined: Wed Dec 18, 2002 4:00 am
Location: newport beach

Post by jiop »

Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

Post 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!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

time() produces a UNIX timestamp, date() takes two arguments: the date formatting options and a timestamp.

Mac
Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

Post by Mr. Tech »

So in phpMyAdmin I need to change uptime to the timestamp command thing? And that will show the date?
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post 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?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

Post by Mr. Tech »

Thanks! I'll give it a try
Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

Post by Mr. Tech »

YAY! Work! THANKS!
Post Reply