user3598640
user3598640

Reputation: 1

How to fetch & show only date on invoice not time

Hi we have invoice concept on our website so at the time of invoice creation we are entering both invoice creation date & time & it is entering in this form in db 2014-05-02 21:53:25 but now what I want to show only date 2014-05-02 to client. Currently in view file of cakephp I am using <td><?php echo ($invoice['Invoice']['created']); ?> so its is showing whole value of data field which has both date & time combine but I want only date to show so for it I tried

 `<?php echo date($invoice['Invoice']['created']); ?>` 

but its not working can any one help me what function should I use to just show date according to my new format.Thanks!

Upvotes: 0

Views: 88

Answers (2)

Salines
Salines

Reputation: 5767

Simple, using cakephp Time helper

<?php echo $this->Time->format('Y-m-d',$invoice['Invoice']['created']); ?>

Upvotes: 1

alreadycoded.com
alreadycoded.com

Reputation: 326

date("Y-m-d",strtotime($invoice['Invoice']['created']));

Upvotes: 1

Related Questions