Subtract dates

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ken

    #1

    Subtract dates

    $expirationdate[0] = 4/15/2005
    $startdate[0] = 3/1/2005

    I would like to determine the number of days between the above dates.

    My approach:
    $startdate = strtotime($star tdate[0]); // change to a string
    $expirationdate = strtotime($expi rationdate[0]);
    $delta = $expirationdate - $startdate; // $delta = 1110175200

    How do I convert $delta to only number of days? // number of days should
    equal 45 days

    Do I need to convert the dates to strings to subtract them?

    Thanks!

    Ken


  • Michael Fesser

    #2
    Re: Subtract dates

    .oO(Ken)
    [color=blue]
    >$expirationdat e[0] = 4/15/2005
    >$startdate[0] = 3/1/2005
    >
    >I would like to determine the number of days between the above dates.
    >
    >My approach:
    >$startdate = strtotime($star tdate[0]); // change to a string
    >$expirationdat e = strtotime($expi rationdate[0]);
    >$delta = $expirationdate - $startdate; // $delta = 1110175200[/color]

    $delta == 3884400
    [color=blue]
    >How do I convert $delta to only number of days? // number of days should
    >equal 45 days[/color]

    round($delta/86400) == 45

    Micha

    Comment

    • Rick

      #3
      Re: Subtract dates

      "Ken" <kkrolski@wi.rr .com> wrote in message
      news:gq7Xd.1792 $Zm4.1570@twist er.rdc-kc.rr.com...[color=blue]
      > $expirationdate[0] = 4/15/2005
      > $startdate[0] = 3/1/2005
      >
      > I would like to determine the number of days between the above dates.
      >
      > My approach:
      > $startdate = strtotime($star tdate[0]); // change to a string
      > $expirationdate = strtotime($expi rationdate[0]);
      > $delta = $expirationdate - $startdate; // $delta = 1110175200
      >
      > How do I convert $delta to only number of days? // number of days should
      > equal 45 days
      >
      > Do I need to convert the dates to strings to subtract them?
      >
      > Thanks!
      >
      > Ken
      >
      >[/color]

      You might try looking at this here.




      Comment

      • Ken

        #4
        Re: Subtract dates

        Thank You!

        Ken

        "Michael Fesser" <netizen@gmx.ne t> wrote in message
        news:fe3q215mgu k8qmpk3f9coit3c tgndckj8j@4ax.c om...[color=blue]
        > .oO(Ken)
        >[color=green]
        > >$expirationdat e[0] = 4/15/2005
        > >$startdate[0] = 3/1/2005
        > >
        > >I would like to determine the number of days between the above dates.
        > >
        > >My approach:
        > >$startdate = strtotime($star tdate[0]); // change to a string
        > >$expirationdat e = strtotime($expi rationdate[0]);
        > >$delta = $expirationdate - $startdate; // $delta = 1110175200[/color]
        >
        > $delta == 3884400
        >[color=green]
        > >How do I convert $delta to only number of days? // number of days should
        > >equal 45 days[/color]
        >
        > round($delta/86400) == 45
        >
        > Micha[/color]


        Comment

        Working...