Solved

how to convert epoch time to human readable time

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

Technology Partners: 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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

734 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