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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:45:23+00:00 2026-05-25T02:45:23+00:00

I Have project in which a module needs to display the list of data

  • 0

I Have project in which a module needs to display the list of data using a group of specific criteria:

Today
Week
Month
Year

The Database table contains a date field which has datatype as BIGINT(10) and through PHP code we insert time() function value into it. which insert some value like 1311144077,

Now I need to fetch the records from my table as per the labels mentionedabove, how can i do that?

  • 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-25T02:45:24+00:00Added an answer on May 25, 2026 at 2:45 am

    While you’re storing datetime in epoch timestamp format, I think solutions using MySQL date/time functions could be very slow. So, I suggest using timestamp itself like below codes.

    Usage example

    $t = time();
    
    # today
    echo date('Y-m-d H:i:s', strtotime('today', $t))."\n";
    echo date('Y-m-d H:i:s', strtotime('tomorrow', $t))."\n";
    
    # this week  
    echo date('Y-m-d H:i:s', strtotime('-1 sunday', $t))."\n";
    echo date('Y-m-d H:i:s', strtotime('sunday', $t))."\n";
    
    # this month  
    echo date('Y-m-d H:i:s', strtotime(date('Y-m-01 00:00:00', $t)))."\n";
    echo date('Y-m-d H:i:s', strtotime(date('Y-m-01 00:00:00', strtotime('next month', $t))))."\n";
    
    # this year
    echo date('Y-m-d H:i:s', strtotime(date('Y-01-01 00:00:00', $t)))."\n";
    echo date('Y-m-d H:i:s', strtotime(date('Y-01-01 00:00:00', strtotime('next year', $t))))."\n";
    

    In query

    # this year
    $start_of_year = strtotime(date('Y-01-01 00:00:00', $t));
    $end_of_year = strtotime(date('Y-01-01 00:00:00', strtotime('next year', $t)));
    $query = "SELECT * FROM sometable WHERE somecolumn >= $start_of_year AND somecolumn < $end_of_year";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a maven multiple-module project, which is giving me headaches in the assembly:assembly
I have a project which is source controlled using Subversion and VisualSVN. Since the
I have a multi-module project, and I am using profiles in the parent pom
Currently I have 1 Guice module in my project which defines all bindings. Now
I have a project which contains different components that everyone works on. We have
I have a project which it's domain contain following classes: Courier Customer Food Order
I have a project which exposes object model to use by different types of
I have a project which builds correctly from the command line. On one of
I have a project which has a set of binary dependencies (assembly dlls for
We have a project which had to be radically descoped in order to ship

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.