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

  • Home
  • SEARCH
  • 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 601229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:41:30+00:00 2026-05-13T16:41:30+00:00

I have this to select a date from a mysql db, and compare it

  • 0

I have this to select a date from a mysql db, and compare it to an array of month-names in swedish language.

$monthnames = array("","Januari","Februari","Mars","April","Maj","Juni","Juli","Augusti","September","Oktober","November","December");

$postdate = $monthnames[date("n", strtotime( $row['modify_date'] ))];
//Outputs something like '12 Februari'

Here is the prob, I want to check the $postdate variable and change it to “Today”, “Yesterday” and “Day before yesterday” according to the date, how can I do so?

Thanks

  • 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-13T16:41:31+00:00Added an answer on May 13, 2026 at 4:41 pm

    If you’re using timestamps to store dates in the database:

    You can have preset intervals like:

    $day = mktime(0,0,0,2,1,2001)-mktime(0,0,0,1,1,2001);
    

    And you can compare the time now – timestamps/dates you have in the database with those intervals.

    For example, let’s say $dbTime contains a timestamp fetched with mysql:

    $time = time() - $dbTime;
    if($time<$day)
       echo 'posted today';
    elseif($time<($day*2))
       echo 'posted yesterday';
    

    etc etc.

    Then you can use PHP’s Date function to echo hrs, minutes, secs, or dates, if they are larger than your predefined intervals.

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

Sidebar

Related Questions

I have a query SELECT date, SUM(cimpression) AS cimp, SUM(cclick) AS cclick FROM stdaily
I have this big table called StateChanges (1.9 million rows) from a third party
$getquery = mysql_query(SELECT * FROM it_task ORDER BY task_id DESC); while ($rows = mysql_fetch_array($getquery))
I have quite a complex MySQL query with a problem but I have narrowed
I'm trying to bind the selected value from the date picker to an asp
i have these two tables , s(id,firstname,lastname,mydate,mount,sh) users(uid,email,password,nameoffice) and this query $sql=SELECT s.id,s.firstname,s.lastname,s.mydate,s.mount,users.nameOffice FROM
I believe this has been a bug/problem in SQL 2000/2005 ... If my results
My question about My SQL is, I have a table where users enter time
Can anyone guide me as to how to set a form to be enabled
I'm new to LINQ and am finding it a bit difficult with understanding some

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.