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 8343097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:57:27+00:00 2026-06-09T05:57:27+00:00

Yet another PHP date question for everyone – I have the current code for

  • 0

Yet another PHP date question for everyone – I have the current code for an English version of my site which works perfectly:

$article = &$articles[$i];

if($currentdate != date("F Y", strtotime($article->getDate()))) {   
    $currentdate = date("F Y", strtotime($article->getDate()));                 
    $current_content1 .= "<div class='press-articles-heading'>" . $currentdate . "    </div>";
}   

Basically what this does is pulls records from a db and compares the date so that the month header is only displayed once, e.g. July 2012 and then all the records for the month, and then June 2012 etc.

If I use the same code on a non-English version of a site I get a bug:

$article = &$articles[$i];

if($currentdate != date("F Y", strtotime($article->getDate()))) {   
    $currentdate = strftime("%B %Y", strtotime($article->getDate()));                 
    $current_content1 .= "<div class='press-articles-heading'>" . $currentdate . "</div>";
}   

What happens here is I get the month header for every db record despite them being the same.

Can’t see where the bug is, has anyone any ideas?

Any help is much appreciated.

Update

I did try a few things before posting the question but thought best to leave it out in order to keep the question simple.

I did try the following:

$article = &$articles[$i];

if($currentdate != date("F Y", strtotime($article->getDate()))) {   
    $translated_date = strftime("%B %Y", strtotime($article->getDate()));                 
    $current_content1 .= "<div class='press-articles-heading'>" . $translated_date . "</div>";
}

But that didn’t solve it

  • 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-06-09T05:57:29+00:00Added an answer on June 9, 2026 at 5:57 am

    Try this:

    $article = &$articles[$i];
    
    $timeString = strtotime($article->getDate());
    $numericDate = strftime('%m %Y', $timeString);
    
    if($currentDate != $numericDate) {
        $currentDate = $numericDate;
        $translatedDate = strftime('%B %Y', $timeString);                 
        $current_content1 .= "<div class='press-articles-heading'>" . $translatedDate . "</div>";
    }
    

    This will make the comparisons based on the numeric value of the month and year, but it will display the localized text value. I used extra variables to cache some date parsing results.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

yet another PHP question which I am stuck on, so here is what im
Yet another PHP question. I've got two arrays: one string-based and the other numeric.
I have yet another issue which the answer is eluding me. I wish to
i have a php code which selects and shows data from my 'elections' table.
I have yet another question regarding the randomization of data! $gender=''; if(isset($_GET['gender'])) { $gender=$_GET['gender'];
I'm working on yet another framework for PHP, and have run into a small
Greetings all, I have yet another RegEx question. I have done hours of searching
After getting a helpful answer here , I have run into yet another problem:
I posted a question before but I am yet limited to mix the code
Here goes a yet another SQL question about dates… I'm building a calendaring application

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.