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
Mr. Tech
Forum Contributor
Posts: 205 Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia
Post
by Mr. Tech » Tue Feb 25, 2003 1:15 am
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 » Tue Feb 25, 2003 2:06 am
Mr. Tech
Forum Contributor
Posts: 205 Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia
Post
by Mr. Tech » Tue Feb 25, 2003 6:20 pm
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!
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Wed Feb 26, 2003 2:40 am
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 » Wed Feb 26, 2003 5:02 pm
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 » Wed Feb 26, 2003 7:23 pm
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?
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Thu Feb 27, 2003 3:49 am
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 » Thu Feb 27, 2003 5:02 pm
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 » Thu Feb 27, 2003 5:08 pm
YAY! Work! THANKS!