user1611830
user1611830

Reputation: 4857

Deleting seconds in a timestamp format - php

I am trying to convert some date 'date' (created with current_timestamp()), and displaying 2013-02-13 17:38:08, and I don't want the seconds to appear. But when I use date('Y-m-d H:i', $date), I get

1970-01-01 01:33 

I think I am not using the right php methods, someone could help ?

Best, Mehdi

Upvotes: 1

Views: 39

Answers (1)

Rusty Fausak
Rusty Fausak

Reputation: 7525

date accepts a parameter as a timestamp, so use strtotime to convert first:

date('Y-m-d H:i', strtotime($date))

might it just be easier to use substr?

Upvotes: 3

Related Questions