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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:42:26+00:00 2026-05-27T10:42:26+00:00

I have removed the desired output and some styling as they dont affect the

  • 0

I have removed the desired output and some styling as they dont affect the question. I cant seem to compare the two dates properly, idea is that if currentDate is greater than deadlineDate there will be no output for that route. What i am trying to do is prevent the system from listing routes which are already closed. I dont understand why its so difficult or then i am missing something very basic here.

<?php
$driveDays = mysql_query("SELECT date,routeid from StopDates where routeid='".$row['id']."' ORDER BY date ASC");

while($stopDates = mysql_fetch_array($driveDays)){
$orderDaysBefore = $row['lastOrderDate']; // How many days before the order must be placed.

// Change the date taken from the query to new format 
$originalDate=($stopDates['date']);
$newDate = date("d.m", strtotime($originalDate));

// Count the deadline date for the route.
$deadlineDate = strtotime ("-".$orderDaysBefore." days +12 hours", strtotime ($originalDate)) ;
$deadlineDate = Date('d.m.y G:i', $deadlineDate);


//Get current date which is then compared to the deadline date. Idea is that if currentDate is larger than deadlinedate there will be no input.
$currentDate=Date("d.m.y G:i"); 


//The line below doesnt seem to be working, i have tried mktime and time too but for some reason it just cant compare.                              
if (strtotime($currentDate) > strtotime($deadlineDate)){
// Output nothing
}
else { ?>

<p>Output stuff here</p>


<?php
}
} 
?>

Problem is that for some rows it hides the route and for some it doesnt. I have tried to do this with mktime and time but i cant seem to figure out what the problem is. Most of the guides i see tell to convert dates to unix timestamp format and if i understand correctly thats exactly what i am trying to do here. Im pretty sure my mistake is a simple one.

Strange thing is that for some dates it seems to work like if deadlineDate is over a month old. deadlineDate forms correctly in the d.m.y G:i format.

Solved

I skipped formatting and compared strtotimes
I added:

$currentDate2=strtotime("now");

$deadlineDate2 = strtotime ("-".$orderDaysBefore." days +12 hours", strtotime ($originalDate)) ;

And then i compare $currentDate2 and $deadlineDate2

  • 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-27T10:42:27+00:00Added an answer on May 27, 2026 at 10:42 am

    Skip the formatting and just compare the results from strtotime().

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

Sidebar

Related Questions

I have two entities // All details has been removed @Entity @Table(name = "A_TABLE_NAME")
I have written some code to remove duplicates from Integer Array. I dont want
I have two peices of code. One produces the desired result the other one
I have following strings: asfagds gfdhdsss dg sdg dsg desired output: asfagds gfdhdsss dg
I have removed all header files within the below path due to numerous errors
There is my site For SEO I have removed the .php extension from all
Between Windows XP and Vista (and server 2003 and 2008) Microsoft have removed the
Since it's integration to the framework, the package seems to have been removed from
I have the following case: Edited: removed link In IE7 gives me different view
It didn't have a project and I removed myself as the assignee, now I

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.