Jump to content

retrieve date and time from mysql field using strtotime


bickyz

Recommended Posts

hi i have a mysql table with upddate and updtime field as follows:

upddate      updtime

2011-02-25  11:03:05

2011-01-28  08:01:09

2011-02-20  07:00:08

2011-02-15  06:10:02

2011-02-05  10:21:04

2011-02-09  10:20:25

 

the data types for upddate is mysql date and for updtime its mysql time

 

In my php page i use

<?php echo $date = date("d M Y",strtotime($row_rs1['upddate'])); ?>

to retrieve date and the results displays as 25 Feb 2011. And for time right now im using

<?php echo $row_rs1['updtime']; ?>

which displays time as 11:03:05

 

I want to display time as HH:MM only, how can i do it?

Use

<?php
list ($date,$time) = explode(' ',date('d M Y H:i',strtotime("{$row_rs1['upddate']} {$row_rs1['updtime']}")));
echo "$date $time";
?>

 

But doing it in the MySQL query would be simpler.

 

Ken

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.