Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unix Timeformat from phpBB in Mysql Database 1

Status
Not open for further replies.

lukelukeluke

Technical User
Joined
Dec 23, 2003
Messages
117
Location
CH
Hi everyone.
I have set up a phpBB on my site. In the phpBB, i definied 1 area as the news area. I want to display its content on my main page.

But now i have problems displaying the time of when the thread was posted.
The timeformat in the mysql database is this as integer: "1089048462".
That should be todays or yesterdays date. But i cant see june or 2004 in this, it must be unix formated timecode.
Now does anyone know how php can transform such a code into 7.5.2004?

Thanks for your ideas.
Bye, Luke
 
That is a unix timestamp. The time() function returns that timestamp. You can use getdate() to convert the timestamp.

For example:

Code:
$dateArray = getdate(time());
print_r($dateArray);

Will get the current timestamp, break it up into an array and print it out. From there you can build whatever date you need.

 
thanks alot for the solution. It worked well for me! Here is what i used:

Code:
<?php
$unix = 1089096751;
$timestamp = getdate($unix);
echo $timestamp[mday].".".$timestamp[mon].".".$timestamp[year].", ".$timestamp[hours].":".$timestamp[minutes];
 
You can do that or use date() with the second optional parameter.

Date() gives you lots of options for formatting that timestamp as a complex date/time string.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top