Steve Joiner
Steve Joiner

Reputation: 503

remove seconds when displaying a datetime database value

I have an html form that uses jQuery datetimepicker to send a value to a database but with out seconds so the value created in the database 'datetime column always has '00' for the seconds. I want to remove the seconds when I display the value on a webpage. I currently have:

<?php echo $row_rsEnquiriesList['contact_date_e']; ?>

which displays something like this - 26-12-08 12:40:00.

I would like it to display this - 26-12-08 12:40

Upvotes: 3

Views: 4089

Answers (2)

OscarAkaElvis
OscarAkaElvis

Reputation: 5714

You can use <?php echo substr($row_rsEnquiriesList['contact_date_e'],0, 14); ?> but is much better to format it on the sql. In this way the date stays as string.

Upvotes: 0

Gowtham
Gowtham

Reputation: 149

You can do it as follow

<?php 

echo date('d-m-y H:i',strtotime($row_rsEnquiriesList['contact_date_e']));

?>

It will remove seconds. and you can remove anything you need.

Upvotes: 7

Related Questions