Re: [PHP] Difference between two dates

2002-02-20 Thread Uma Shankari T.



Hello,


  I got the solution for the date difference problem..,,

Thankyou very much.



-Uma




"Uma Shankari T." <[EMAIL PROTECTED]> wrote:
> If i gave the str date as "31-01-2001"; and  $str1="04-02-2001"; then it
> is displaying the wrong result
>
> Plz tell me how can i rectify this problem...

Uma,

I wrote a function last year that calculates the time between 2 dates in
whatever unit is preferred (everything from seconds to years).  My function
expects the date in a slightly different format, but it would be trivial to
switch the order of the date parts in one line and hard-code something for
the hours, minutes and seconds it expects in the date format.  It wouldn't
matter what you hardcode them as since it would use the same time of day for
both dates.

http://www.befriend.com/code_gallery/php/get_elapsed_time/

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Difference between two dates

2002-02-20 Thread Steve Werby

"Uma Shankari T." <[EMAIL PROTECTED]> wrote:
> If i gave the str date as "31-01-2001"; and  $str1="04-02-2001"; then it
> is displaying the wrong result
>
> Plz tell me how can i rectify this problem...

Uma,

I wrote a function last year that calculates the time between 2 dates in
whatever unit is preferred (everything from seconds to years).  My function
expects the date in a slightly different format, but it would be trivial to
switch the order of the date parts in one line and hard-code something for
the hours, minutes and seconds it expects in the date format.  It wouldn't
matter what you hardcode them as since it would use the same time of day for
both dates.

http://www.befriend.com/code_gallery/php/get_elapsed_time/

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Difference between two dates

2002-02-19 Thread Uma Shankari T.


 

  If i gave the str date as "31-01-2001"; and  $str1="04-02-2001"; then it
is displaying the wrong result

Plz tell me how can i rectify this problem...


-Uma

 




On Tue, 19 Feb 2002, Rasmus Lerdorf wrote:

RL>This will give you the difference between the two dates in seconds:
RL>
RL>$diff = strtotime(str_replace('-','/',$str1)) - 
strtotime(str_replace('-','/',$str));
RL>
RL>-Rasmus
RL>
RL>On Wed, 20 Feb 2002, Uma Shankari T. wrote:
RL>
RL>>
RL>>
RL>>
RL>>  Hello,
RL>>
RL>>  How can i find out the difference between two dates.
RL>>
RL>> I am having the date like this
RL>>
RL>> $str="10-01-2001";
RL>> $str1="01-02-2002";
RL>>
RL>> I need to find out the difference between the date,month and year.
RL>>
RL>> If anyone know the solution for this problem plz tell me
RL>>
RL>>
RL>> -Uma
RL>>
RL>>
RL>>
RL>> --
RL>> PHP General Mailing List (http://www.php.net/)
RL>> To unsubscribe, visit: http://www.php.net/unsub.php
RL>>
RL>

-- 

Love and you shall be loved by others


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Difference between two dates

2002-02-19 Thread Steven Walker

You can convert the time into seconds using mktime(), subtract one from 
the other, and then reformat it using gmstrftime:

//int mktime ( int hour, int minute, int second, int month, int day, int 
year [, int is_dst])
//string gmstrftime ( string format [, int timestamp])
";
echo "$time2";
echo "$dif";
echo "$new_time";
?>
The output looks like this:
883641600
820396800
63244800
Jan 03 1972

Of course you will have to get the date out of the current format you 
have it, but that shouldn't be too hard using explode() and implode();

Steven J. Walker
Walker Effects
www.walkereffects.com
[EMAIL PROTECTED]

On Tuesday, February 19, 2002, at 06:51  PM, Uma Shankari T. wrote:

>
>
>
>  Hello,
>
>  How can i find out the difference between two dates.
>
> I am having the date like this
>
> $str="10-01-2001";
> $str1="01-02-2002";
>
> I need to find out the difference between the date,month and year.
>
> If anyone know the solution for this problem plz tell me
>
>
> -Uma
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



Re: [PHP] Difference between two dates

2002-02-19 Thread Rasmus Lerdorf

This will give you the difference between the two dates in seconds:

$diff = strtotime(str_replace('-','/',$str1)) - strtotime(str_replace('-','/',$str));

-Rasmus

On Wed, 20 Feb 2002, Uma Shankari T. wrote:

>
>
>
>  Hello,
>
>  How can i find out the difference between two dates.
>
> I am having the date like this
>
> $str="10-01-2001";
> $str1="01-02-2002";
>
> I need to find out the difference between the date,month and year.
>
> If anyone know the solution for this problem plz tell me
>
>
> -Uma
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Difference between two dates

2002-02-19 Thread Uma Shankari T.




Hello,

  If i executed code then nothing will be displayed...


-Uma 


On Tue, 19 Feb 2002, Andrey Hristov wrote:

AH>Try this :
AH>$d1=strtotime('d-m-Y',$str);
AH>$d2=strtotime('d-m-Y',$str1);
AH>var_dump($d2-$d1);
AH>
AH>
AH>Best regards,
AH>Andrey Hristov
AH>
AH>- Original Message - 
AH>From: "Uma Shankari T." <[EMAIL PROTECTED]>
AH>To: <[EMAIL PROTECTED]>
AH>Sent: Tuesday, February 19, 2002 10:50 AM
AH>Subject: [PHP] Difference between two dates
AH>
AH>
AH>> 
AH>> 
AH>>  Hello,
AH>> 
AH>>  How can i find out the difference between two dates.
AH>> 
AH>> I am having the date like this
AH>> 
AH>> $str="10-01-2001";
AH>> $str1="01-02-2002";
AH>> 
AH>> I need to find out the difference between the date,month and year.
AH>> 
AH>> If anyone know the solution for this problem plz tell me
AH>> 
AH>> 
AH>> -Uma 
AH>> 
AH>> 
AH>> -- 
AH>> PHP General Mailing List (http://www.php.net/)
AH>> To unsubscribe, visit: http://www.php.net/unsub.php
AH>> 
AH>> 
AH>

-- 

Love and you shall be loved by others



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Difference between two dates

2002-02-19 Thread Andrey Hristov

Try this :
$d1=strtotime('d-m-Y',$str);
$d2=strtotime('d-m-Y',$str1);
var_dump($d2-$d1);


Best regards,
Andrey Hristov

- Original Message - 
From: "Uma Shankari T." <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 19, 2002 10:50 AM
Subject: [PHP] Difference between two dates


> 
> 
>  Hello,
> 
>  How can i find out the difference between two dates.
> 
> I am having the date like this
> 
> $str="10-01-2001";
> $str1="01-02-2002";
> 
> I need to find out the difference between the date,month and year.
> 
> If anyone know the solution for this problem plz tell me
> 
> 
> -Uma 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Difference between two dates

2002-02-19 Thread Daniel Alsén

Read this article at PHPbuilder:

http://www.phpbuilder.com/columns/akent2610.php3

- D


- Original Message - 
From: "Uma Shankari T." <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 19, 2002 9:50 AM
Subject: [PHP] Difference between two dates


> 
> 
>  Hello,
> 
>  How can i find out the difference between two dates.
> 
> I am having the date like this
> 
> $str="10-01-2001";
> $str1="01-02-2002";
> 
> I need to find out the difference between the date,month and year.
> 
> If anyone know the solution for this problem plz tell me
> 
> 
> -Uma 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php