1

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

Praveen Srinivasan
  • 1,494
  • 4
  • 23
  • 52
  • 1
    possible duplicate of [Convert a Unix timestamp to time in Javascript](http://stackoverflow.com/questions/847185/convert-a-unix-timestamp-to-time-in-javascript) – wonderb0lt Jun 15 '15 at 09:45
  • Are you doing this in the controller in php or after you have sent it from the controller in javascript – haakym Jun 15 '15 at 09:49

2 Answers2

2

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/

teoreda
  • 2,186
  • 1
  • 19
  • 26
1

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/

haakym
  • 11,222
  • 10
  • 63
  • 93