Re: [PHP] date calculation

2003-02-16 Thread Stephen Willcock
Try:

$today = strtotime ("1 february 2003");
$enddate = strtotime ("2 february 2003");
$diff = $enddate - $today;

Should give you a clue!

SW


"Qt" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Dear Kevin,
>
> I used timestamp allready as following;
>
> $today = strtotime ("1 february 2003");
> $enddate = strtotime ("1 march 2003");
>
> $diff = $enddate - $today;
>
> But result comes as
>
> 2419200
>
> How can I convert that numbers to days
>
> Best Regards
>
>
>
> "Kevin Waterson" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > This one time, at band camp,
> > "qt" <[EMAIL PROTECTED]> wrote:
> >
> > > Dear Sirs,
> > >
> > > How can I add or subtract two date easily. Is therea any lib or
function
> > > about this. I can not find any easy way in the manual
> >
> > if the dates are timestamps, simply
> >
> > $new = $timestamp2 - $timestamp1;
> >
> > cheers
> > Kevin
> >
> > --
> >  __
> > (_ \
> >  _) )           
> > |  /  / _  ) / _  | / ___) / _  )
> > | |  ( (/ / ( ( | |( (___ ( (/ /
> > |_|   \) \_||_| \) \)
> > Kevin Waterson
> > Port Macquarie, Australia
>
>



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




Re: [PHP] date calculation

2003-02-16 Thread Stephen Willcock
Yes, will be OK with all dates (though the valid range of a timestamp is
typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07
GMT.)

The function you want for numeric dates is:
int mktime ( int hour, int minute, int second, int month, int day, int year)

so, in your example (1st Feb 2003):
$mydate = mktime(0,0,0,2,1,2003);

SW


"Qt" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Dear Stephen,
>
> Good clue!!
>
> Is it working allways without problem such as 29 feb?
>
> And one more hel how can I write "1 2 2003" instead of  "1 february 2003"
>
> I wrote but directly but doesn' t work
>
> thanks
>
> "Stephen Willcock" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Try:
> >
> > $today = strtotime ("1 february 2003");
> > $enddate = strtotime ("2 february 2003");
> > $diff = $enddate - $today;
> >
> > Should give you a clue!
> >
> > SW
> >
> >
> > "Qt" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > Dear Kevin,
> > >
> > > I used timestamp allready as following;
> > >
> > > $today = strtotime ("1 february 2003");
> > > $enddate = strtotime ("1 march 2003");
> > >
> > > $diff = $enddate - $today;
> > >
> > > But result comes as
> > >
> > > 2419200
> > >
> > > How can I convert that numbers to days
> > >
> > > Best Regards
> > >
> > >
> > >
> > > "Kevin Waterson" <[EMAIL PROTECTED]> wrote in message
> > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > > This one time, at band camp,
> > > > "qt" <[EMAIL PROTECTED]> wrote:
> > > >
> > > > > Dear Sirs,
> > > > >
> > > > > How can I add or subtract two date easily. Is therea any lib or
> > function
> > > > > about this. I can not find any easy way in the manual
> > > >
> > > > if the dates are timestamps, simply
> > > >
> > > > $new = $timestamp2 - $timestamp1;
> > > >
> > > > cheers
> > > > Kevin
> > > >
> > > > --
> > > >  __
> > > > (_ \
> > > >  _) )           
> > > > |  /  / _  ) / _  | / ___) / _  )
> > > > | |  ( (/ / ( ( | |( (___ ( (/ /
> > > > |_|   \) \_||_| \) \)
> > > > Kevin Waterson
> > > > Port Macquarie, Australia
> > >
> > >
> >
> >
>
>



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




[PHP] Re: Default argument values

2003-02-17 Thread Stephen Willcock
Yes, you can call your function with these arguments, but in this case of
course the defaults will not be used because you have supplied arguments.
SW


"Neko" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hey All,
>
> I've been trying to write a function that accepts multiple optional
> parameters, some of which are ints. The function signature looks like
this:
>
> function blahBlah($fromDate, $toDate = 0, $limit = 20, $limitNodeType =
> null)
>
> I've been reading up here:
>
> http://www.php.net/manual/en/functions.arguments.php
>
> But it doesn't describe what to do with multiple optional arguments. Can I
> call the function like this:
>
> blahBlah($date, null, null, $limitNodeType);
>
>
> ?
>
> Need some help getting this language feature sorted.
>
> cheers,
> neko



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