Solved

how to convert epoch time to human readable time

Posted on 2007-12-01
5
6,360 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Wordpress Security 29 71
$_GET call between URL 3 38
Make checkboxes execute queries on click 8 31
restriction of entering a a page 5 31
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

735 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