Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3697738
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:53:47+00:00 2026-05-19T04:53:47+00:00

I wish to only write out(Y) the year, if only its not from the

  • 0

I wish to only write out(Y) the year, if only its not from the current year we’re on.

function get_day_name($timestamp) {
    $date = date('j-m-Y', $timestamp);
    if($date == date('j-m-Y')) {
      $day_name = 'Today';
      echo 'idag ';
    } else if($date == date('j-m-Y',time() - (24 * 60 * 60))) {
      $day_name = 'Yesterday';
      echo 'igår ';
    }else{
    # How can i check here whether the $timestamp is from this year or last year?
    # If it is from this year then it shouldnt write out the "Y" in $date
    echo $date;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:53:48+00:00Added an answer on May 19, 2026 at 4:53 am

    Based on the comment in your original post

    # How can i check here whether the $timestamp is from this year or last year?
    

    I thought you were asking how you could check to see if the timestamp year was from this year or last year. So, I thought you meant you wanted to know, for example, if the year was 2011 or 2010. What you really want to know is whether the timestamp year is from this year, or any other year, be it 2010, 2009, etc.

    This was my first answer, based on my misunderstanding…

    $current_year = date('Y');
    $timestamp_year = date('Y', $timestamp);
    if ($timestamp_year == $current_year || $timestamp_year == $current_year - 1)
    

    This is how you would want to do it:

    if (date('Y') == date('Y', $timestamp)) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large function that I wish to load only when it is
I wish to send an email from my localhost machine (using PHPs mail function)
I wish to get a particular set of files and the only access I
I wish to compare to nested lists of unequal length. I am interested only
I wish to be able to write entries to a console application which will
I wish to write a query which will replace the value0.00 with - in
I am trying to write the following function in C, char* modelstrdup(char* source); The
I wish to set an NSError pointer from within a block in a project
I am trying to write some css rules which should only affect the TextFields
All, I wish to write a plugin .dll to be used/called by a .NET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.