Jump to content

Coding A Date From DB


refiking

Recommended Posts

I have a countdown applet that requires I seperate each value from the date stored in the DB.  How can I seperate these values correctly.  When I tried it, it gave me the following result:

 

1969

12

31

07

33

28

 

Here is my current code as is:

<?php
$lid = 1;
$sid = 21;
include 'cont.php';
$sql = mysql_query("SELECT * FROM dlg WHERE lid = '$lid' AND sid = '$sid' LIMIT 1");
while($row = mysql_fetch_array($sql)){
$newdate = $row['dtime'];
}
$year = date('Y', $newdate);
$month = date('m', $newdate);
$day = date('d', $newdate);
$minute = date('i', $newdate);
$hour = date('h', $newdate);
$second = date('s', $newdate);
echo $year."<br>".$month."<br>".$day."<br>".$hour."<br>".$minute."<br>".$second;
?>

Link to comment
https://forums.phpfreaks.com/topic/99046-coding-a-date-from-db/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.