Jump to content

Php!? How to count a difference between to dates(time), not in UNIX format?

- - - - -

  • Please log in to reply
2 replies to this topic

#1
Stasonix

Stasonix

    Learning Programmer

  • Members
  • PipPipPip
  • 82 posts
  • Programming Language:C++, PHP, JavaScript, Delphi/Object Pascal, Pascal
  • Learning:C++, PHP, JavaScript, Delphi/Object Pascal
for example:
current time - sometime = 10 min. (how to count this?)
when do it like:
$curtime = time();
$diff = $curtime - $sometime;
if return me the UNIX format, but I need to understand how much it is in normal format?
just 10 min. must be 10, not 123124123123.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Unix Time Stamp . com
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
The Unix timestamp will be of seconds since January 1st, 1970 00:00. You can easily differentiate them, for example $curtime - $sometime will return 7200, 7200 is exactly two hours in seconds from the current time.

echo ($diff / 60) . " minutes";

Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users