Forum Moderators: coopster

Message Too Old, No Replies

Epoch Time to a more user friendly view

Epoch Time to a more user friendly view

         

PRosales

7:57 pm on May 3, 2005 (gmt 0)

10+ Year Member



I have the need to convert epoch times to their more user friendly state. Can someone please enlighten me on how to do so?

The following are example times:

1109630588
1109634823
1109661921
1109696511
1109698732
1109699923
1109699939

The ideal output would present the year/month/day.

Any guidance is truly appreciated.

Pete Rosales

bcolflesh

8:11 pm on May 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$timestamp = 1109630588;
echo date("Y-m-d", $timestamp);

[us2.php.net...]

PRosales

8:46 pm on May 3, 2005 (gmt 0)

10+ Year Member



I am sorry, I should have also stated that I the usage I am attempting to achieve.

Currently I have the following code:

<?php

$sql = "SELECT DISTINCT DATE_FORMAT(insert_dt_tm, '%Y-%m-%d') as day_start
FROM
Nodes_Available_March_2005";
$result = mysql_query($sql) or die(mysql_error());
echo "<form action='secondPage.php'>";
echo "<select name='day_start'>";
while ($row = mysql_fetch_assoc($result)) {
echo "<option value='{$row['day_start']}'>{$row['day_start']}</option>";
}
echo "</select>";
echo "</form>";
?>

This displays a drop down selection of the dates in the database. this works beautifully for the time inputted into the database as:

2005-01-08 01:03:00
2005-01-08 02:03:00
2005-01-08 03:03:00
2005-01-08 04:03:00
2005-01-08 05:03:00

The time has been changed to be the aforementioned epoch time.

The handling of this change is where my trouble is.

bcolflesh

8:52 pm on May 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use FROM_UNIXTIME instead of DATE_FORMAT:

[dev.mysql.com...]

PRosales

10:33 pm on May 3, 2005 (gmt 0)

10+ Year Member



bcolflesh,

Thanks for the help. It is working like a charm.

Pete Rosales