help with date changes

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

    help with date changes

    Can some tell me how I could change
    1965-11-15 into just 1965.

    I need to calculate ages so I will just get
    $year = date(Y);
    $age = $year - $birthYear;


    TIA,
    Kelly
  • Geoff Berrow

    #2
    Re: help with date changes

    I noticed that Message-ID: <VkWgc.169529$P k3.53547@pd7tw1 no> from Kelly
    contained the following:
    [color=blue]
    >Can some tell me how I could change
    >1965-11-15 into just 1965.
    >
    >I need to calculate ages so I will just get
    >$year = date(Y);
    >$age = $year - $birthYear;[/color]

    $x=date('Y');
    $y=date('Y',str totime("1965-11-15"));
    $age=$x-$y;
    print "$age";

    --
    Geoff Berrow (put thecat out to email)
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs http://www.ckdog.co.uk/rfdmaker/

    Comment

    • Kelly

      #3
      Re: help with date changes

      Thanks actually I just exploded the other date and took the year from it.
      "Geoff Berrow" <blthecat@ckdog .co.uk> wrote in message
      news:45m880l8ut hilbd6j8vr0e8kn 59la7vejn@4ax.c om...[color=blue]
      > I noticed that Message-ID: <VkWgc.169529$P k3.53547@pd7tw1 no> from Kelly
      > contained the following:
      >[color=green]
      > >Can some tell me how I could change
      > >1965-11-15 into just 1965.
      > >
      > >I need to calculate ages so I will just get
      > >$year = date(Y);
      > >$age = $year - $birthYear;[/color]
      >
      > $x=date('Y');
      > $y=date('Y',str totime("1965-11-15"));
      > $age=$x-$y;
      > print "$age";
      >
      > --
      > Geoff Berrow (put thecat out to email)
      > It's only Usenet, no one dies.
      > My opinions, not the committee's, mine.
      > Simple RFDs http://www.ckdog.co.uk/rfdmaker/[/color]


      Comment

      • Geoff Berrow

        #4
        Re: help with date changes

        I noticed that Message-ID: <Op2hc.172944$P k3.70145@pd7tw1 no> from Kelly
        contained the following:
        [color=blue]
        >Thanks actually I just exploded the other date and took the year from it.[/color]

        strtotime() accepts a wider range of separators

        --
        Geoff Berrow (put thecat out to email)
        It's only Usenet, no one dies.
        My opinions, not the committee's, mine.
        Simple RFDs http://www.ckdog.co.uk/rfdmaker/

        Comment

        Working...