How to get the previous year from the date

Discussion in 'PHP' started by mylooieva, Jun 18, 2009.

  1. #1
    i want to calculate the year start from the working day until now. i can get the date of the working date but if i just want to get the year of the working date, is it possible? Can anyone help me? i not using the TIMESTAMP in declare date in database. i using DATE. thanks!!
     
    mylooieva, Jun 18, 2009 IP
  2. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #2
    Your question in the post is not clear to me, but as far question in your topic title, code is:

    $previous_year = intval(date("Y", $TIMESTAMP)) - 1;

    regards
     
    Vooler, Jun 18, 2009 IP
  3. aquasonic

    aquasonic Well-Known Member

    Messages:
    90
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    115
    #3
    Ha ha - yeh that doesn't make a great deal of sense! What do you mean by
    And what is the "working date"?!
     
    aquasonic, Jun 18, 2009 IP
  4. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #4
    $last_year = date('Y',strtotime(' -1 Year',strtotime($date_from_db)));
     
    jestep, Jun 18, 2009 IP
  5. mylooieva

    mylooieva Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thank jestep. I already can get the ans from your post. And hundred of appologize because of my broken english making reader feel difficulty to understand what i wanted.

    $year = date('Y',strtotime(' 0 Year',strtotime($date_from_db)));
     
    mylooieva, Jun 18, 2009 IP