-2

I have a date with this format

Fri Feb 07 17:22:23 +0000 2014

How can calculate difference with server current time in php?

I try

date('D M d H:i:s Y');
date_diff

but no luck

Yashar Khavan
  • 1,615
  • 1
  • 17
  • 14

2 Answers2

0

Convert both times to UNIX time (i.e. times since the epoch).

You get the difference in seconds between the two.

Then just do the mathematics

Ed Heal
  • 59,252
  • 17
  • 87
  • 127
0

first and second date time

$myd1 =  strtotime('Fri Feb 07 17:22:23 +0000 2014');
$myd2 = strtotime('now');

difference

$d1 = $myd2 - $myd1;

hours minutes seconds as you asked

$hours = (int)($d1/3600);
$kalan= $d1 % 3600;
$minutes = (int)(($kalan) / 60);
$seconds = ($d1 % 60 ) ;
Nihat
  • 3,055
  • 3
  • 18
  • 28