Yii Framework Forum: how to calculate difference between two dates - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

how to calculate difference between two dates Rate Topic: -----

#1 User is offline   vikram 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 60
  • Joined: 24-June 09

Posted 02 July 2009 - 06:33 AM

a=02-08-2009 or 2009-08-02
b=03-08-2009 or 2009-08-03

when subtracting it i should get the answer as 1............do someone tell me
0

#2 User is offline   Dave 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 187
  • Joined: 09-October 08

Posted 02 July 2009 - 07:17 AM




$diff = strtotime("2009-08-03") - strtotime("2009-08-02");
$days = $diff / 60 / 60 / 24




3

#3 User is offline   vikram 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 60
  • Joined: 24-June 09

Posted 28 July 2009 - 11:01 AM

View PostDave, on 02 July 2009 - 07:17 AM, said:

<pre class='prettyprint'>
$diff = strtotime("2009-08-03") - strtotime("2009-08-02");
$days = $diff / 60 / 60 / 24
</pre>

yes thanks i got it
thanks to the hearts that wishes to clear my doubt or to help me
vikram
0

#4 User is offline   tpandi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 22-May 12

Posted 13 September 2012 - 04:21 AM

how to subtract between two different times

12.00.00 - 03.30.00

please help me


0

#5 User is offline   ORey 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,694
  • Joined: 20-April 09
  • Location:Moscow, Russia

Posted 13 September 2012 - 06:25 AM

$from = strtotime("2012-09-12 12:00:00");
$to = strtotime("2012-09-13 03:30:00");
$diff = round(abs($to - $from) / 60, 2);


View Posttpandi, on 13 September 2012 - 04:21 AM, said:

how to subtract between two different times

12.00.00 - 03.30.00

please help me

God is real unless declared as integer
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users