Solved

how to convert epoch time to human readable time

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now