Solved

how to convert epoch time to human readable time

Posted on 2007-12-01
5
6,372 Views
Last Modified: 2013-12-13
Hi,

I like to know if there is a function or method anyone would know in PHP that converts epoch time to human readable time.

Thanks
0
Comment
Question by:dmehran
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 21

Accepted Solution

by:
nizsmo earned 500 total points
ID: 20390017
There sure is, please use the date function, like this as an example:

<?php
      echo date("Y-m-d","1196559376");
?>
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20390022
More information on the date() function here:
http://www.php.net/date

basically you supply a string as the first argument, and your epoch time as your second argument.

To get the full deal something like this would display the time as well:

<?php
      echo date("Y-m-d H:i:s","1196559376");
?>

Hope this helps, to get more examples on what string you should use in the first argument, please refer to the site above.
0
 

Author Closing Comment

by:dmehran
ID: 31412151
Oh my, I am not sure how this slipped under my radar! For whatever reason I was thinking of something way more complicated than passing couple of arguments to the date function.

Thanks
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20394427
no problem glad to help! :)
0
 
LVL 1

Expert Comment

by:a2liter
ID: 20725683
Here is a handy function that I use all the time, you cna just add formats to return to your hearts content. These are just the most common ones that I use.


function sec2date($ticks,$method = 1){
 if ($method == 1)
  $date= date("Y-m-d H:i:s", $ticks);
 else if ($method == 2)
  $date= date("m/d/y H:i:s", $ticks);
 return $date;
}

Open in new window

0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question