Reputation: 1620
I am using laravel 5.0. I am getting data from controller as json. I am having value like this.
{"timstamp_date":"1434360957"},
I need to convert this unix timestamp value as Normal Date Like (15-06-2015)
or (15-March-2015)
.
I have used Date(timstamp_date)
but it is showing current time only. Not my timstamp date
Upvotes: 1
Views: 7805
Reputation: 2580
You could use:
date("d-m-Y H:i:s", 1434360957);
EDIT You could try;
var dateTime = new Date(1434360957*1000);
var formatted = dateTime.toGMTString();
https://jsfiddle.net/sp57Lnpf/
Upvotes: 3
Reputation: 12358
Use the date function. You need to specify the format as the first parameter:
date("d-m-Y", $timestamp_date)
http://php.net/manual/en/function.date.php
Laravel also comes with Carbon you could use that if you wanted to for further manipulation of the data if you so required it.
http://carbon.nesbot.com/docs/
Upvotes: 1