0

I am using the following query to display a timestamp from a database:

    <?php echo $testimonial->dated; ?>

this query displays the timestamp as follows: yyyy-mm-dd hh:mm:ss

I tried different date functions in order to display it in the format dd/mm/yyyy but did not have any luck with it, since I dont get how to correctly add this to the query mentioned above. Any idea on how to get this sorted? Thanks so much in advance :)

Ben
  • 83
  • 1
  • 12
  • There are literally hundreds (probably thousands) of questions here addressing this. [Here's one which will set you on the right path](http://stackoverflow.com/questions/2167916/convert-one-date-format-into-another-in-php/2167925#2167925). And [another](http://stackoverflow.com/questions/136782/format-mysql-datetime-with-php/136872#136872) – Michael Berkowski Oct 13 '13 at 20:34

2 Answers2

1
<?php echo date("d/m/Y", strtotime($testimonial->dated));?>
Jonysuise
  • 1,790
  • 13
  • 11
  • 1
    Thanks for your help, this solved it for me :) Thanks to everyone else, too, you are great guys :) – Ben Oct 13 '13 at 20:48
0

I didn't understand very well, but:

If this returns a date format (Y-m-d H:i:s) and you want to get the timestamp:

<?php echo strtotime($testimonial->dated); ?>

If this returns a timestamp and you want to get the date format:

<?php echo date('Y-m-d H:i:s', $testimonial->dated); ?>