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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:48:36+00:00 2026-05-12T06:48:36+00:00

Before i start id like to say ive posted this question as more of

  • 0

Before i start id like to say ive posted this question as more of a discussion rather than Problem Question.

In my Database i have news posts lets say with 3 columns (Id, title, date). Wher Id and title are self Explanitory the date is stored in mktime() values, in other words the number of seconds passed since 1 January 1970.

Now what i want to do is build an archive link that will display as such

  • July 2009
  • June 2009
  • March 2009
  • Feburary 2009
  • December 2008

Note the months on which there were no posts are not displayed.

Now as an initial thought i was thinking

  1. Start with the last day of the current Month
  2. And get the Value of the First day of the current Month
  3. Do a MySQL COUNT Query/mysql_num_rows for posts that were date >= First_Day_Seconds AND date <= Last_Day_Seconds
  4. Display or put the values in an Array
  5. Do another Query to Check if Any more values are found WHERE date < First_Day_Seconds (break if no rows were found)

Now the above is just something on the top of my head. But if you got any ideas to speed this process up please share.

Will say in advance, date needs to be in mktime format

  • 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-12T06:48:36+00:00Added an answer on May 12, 2026 at 6:48 am

    I would suggest using a database “native” time format, but it works with UNIX timestamps as well.

    You can simply do:

    SELECT DISTINCT FROM_UNIXTIME(date, '%M %Y') FROM posts;
    

    Optionally with a WHERE clause limiting the dates to past or future dates. Possibly an ORDER clause thrown in for good measure. That should be pretty much all that’s needed, let the database do as much work as possible.

    If you need more formatting options, select the dates with "%Y-%m" instead and format them in PHP:

    date($myCustomFormat, strtotime("$date-01"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Before I start I should say I know this seems like a long shot,
Let's say I'd like to start a small linux distro before my ordinary operating
before I start I want to point out that I tagged this question as
(Before I start, yes I have asked a similar question before; unfortunately due to
To start off, I'd like to say I'm rather unfamiliar with the Windows linking
Am using Mediainfo library in my C# project,before start invoking this dll,i just ran
I'm trying to get some better logic behind this before I start writing code.
Assuming I have a table like this one: CREATE TABLE user_delegates ( [id] INT
I have to solve a following problem. there are many files let's say 3
I would like to get text width of a string before an application starts.

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.