-1

I am currently outputting a timestamp from my database (code below) but it's in the wrong format.

<p>{$row->last_updated}</p>

It is currently outputting 2018-10-23 13:36:40

The time is ok but the date isn't. This is what I want:

23-10-2018 13:36:40

What do I need to do with this code in order to display it like that?

Barry
  • 3,216
  • 7
  • 22
  • 42
PeterT
  • 39
  • 5

2 Answers2

1

You can use date()

<p><?php echo date('d-m-Y H:i:s',strtotime($row->last_updated));?></p>
Anant Kumar Singh
  • 68,309
  • 10
  • 50
  • 94
1

You can change date format using PHP date function like this :

date('d-m-Y H:i:s', strtotime($row->last_updated))
Hemant
  • 11
  • 1