Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Strtotime() - Compare Two Dates


i dont get the format for it, say i have a date 06-06-2003, will it read that as month/day/year or day/month/year?

what about mysql dates. 2003-06-06 how does it read those? i just want to compare two dates.




View Complete Forum Thread with Replies

Related Forum Messages:
Comparing Dates With Strtotime()
I'm building a schedule script--well, modifying one I built last year--to add an event every second and third Sunday of the month.  However, when I try to find that Sunday, and compare to my timestamp, I run into trouble: $myDays = getMyDays(); Code:

View Replies !
Difference Between Two Dates Using Strtotime
im having some problem regarding strtotime and date function.. i want to find the difference between two dates using strtotime.. and then use the difference in loop to determine the dates between the two given dates... but instead of year 2007.. the output year is 2001.. how come? here's my code:

View Replies !
Strtotime - Get The Dates Converted?
I inherited a website with an SQL database. I need to pull information from the database into Excel for future use but the date fields are in strtotime from what I can tell. (Example: 1149996306). Is there a formula I can plug into Excel that would allow me to convert these dates to actual dates I can use? Or is there a SQL script that I can insert in MySQL or Access to get the dates converted?

View Replies !
Is It Possible To Compare Dates?
Is it possible to compare dates? For example: I have a site that displays releases dates (in MySQL format) for upcoming CDs. However, I need to compare the current date with the release date to decide whether or not to display a release date at all.

View Replies !
Compare Two Dates
Comparing UNIX timestamps is no biggie but i have
to compare dates like this

$expiry_date="01/22/2007 05:42 PM";

to be compared with

$now= "01/22/2006 05:42 PM";

and just want a simple TRUE/FALSE return for the condition

"If expiry date has arrived? if its expiry date today or expiry date has passed?"

View Replies !
Is There A Way To Compare The Dates?
I have 2 databases. The first database I am pulling information to create a report that calculates entries for all the different dates and categories. I have the query grouping the results into weeks. Now from the second database I have to pull additional information and then find a way to compare the dates to the first database and place the information into the correct week that was grouped from the first database. is there a way to compare the dates? Like if the date from the second database is between this date range place it with this week for output.

View Replies !
Compare 2 Dates
we have this 2 different dates,

$a = 2004 - 12 - 12 and $b = 2004 - 12 - 30

is possible for us in php to do:

if ($a < $b) // possible to do this?
{}

View Replies !
Compare Dates
is it possible to compare two dates, one set in a record in a mysql database and the other one is todays date (getdate) If getdate >= date in database, then the rest of the fields of that record should be displayed, if not, nothing of that record should be showed. Is this possible and how ?

View Replies !
How To Compare 2 Dates In Mysql As Mysql Treats Dates As String ?
I'm trying to compare two dates in MYSQL. But its not treating the dates as numbers, but as strings. I try using strtotime but that did not work.

View Replies !
Compare 2 Dates But I Can't Get It To Work.
I Want to compare 2 dates but i can't get it to work. First date is $aujourd'hui and the second is a VARCHAR in my database (both have the format YYYY/MM/DD)

$aujourdhui = date("Y/m/d", strtotime("-6 hours"));

$stmt_visiteur = mysql_query("SELECT * FROM pool_calendrier WHERE date = $aujourdhui");

$myrow5 = mysql_fetch_array($stmt_visiteur);
$visiteur = $myrow5['date'];
echo $visiteur;

View Replies !
Compare The Dates On Submit
this must be basic but I'm a bit at a loss. I need to compare the dates on submit, and if submitted date (0000-00-00) is less then today's date, spit out a message.

View Replies !
Compare Two String Dates Using An IF Statement?
How do I compare two date stored within a database with datatype 'date'?

The dates are stored within a PostgreSQL database table in the format
"Y-m-d".

View Replies !
Compare Dates Just Like Normal Numbers In PHP.
In my database, the Valid_end column is formated with the date datatype. My question is, after getting the values from the database, is it possible to compare them just like normal numbers in PHP. Or is there a much efficient way to do this. PHP Code:

View Replies !
Compare Dates With The Current Date
I have two mysql DATA (YYYYMMDD) fields, and i want to compare them with the current date on my webserver. I want the current date to be belong DATE in the interval made by my two mysql fields. Code:

View Replies !
Compare Two Dates In A Booking System
i want to compare two dates called booking_start_date and booking_end_date to make sure that the booking start date comes before the booking end date. at the moment both dates are just stored as dates in the mysql database. anybody know how i could do this?

and also does anybody know how i can find the number of days that the booking is for based on the dates that the user has entered as it will be needed for me to calculate the price of their overall booking.

View Replies !
Compare With Dates In A SQL Server Database
I have a date from a html form and I want to compare it with dates in a SQL Server Database. The html form date has this format: YYYY-MM-DD And I formatted the Database date to this: YYYY-MM-DD So is the below the correct way of checking if the dates clash?PHP Code:

if(($class_start >= $date_start_db) && ($class_start <= $date_end_db)
|| ($class_end > $date_start_db) && ($class_end <= $date_end_db)
|| ($class_start <= $date_start_db) && ($class_end > $date_start_db))

View Replies !
Compare 2 Dates Problem (select * From 2 Days Ago)
I am having a problem with comparing 2 dates with eachother. I wan't to select everything from a table from today and 2 days ago. PHP Code:

View Replies !
Take Todays Date, Compare It With The Dates Held In The Db
I have a db which has a field called 'date' and is set to date type. I want to be able to take todays date, compare it with the dates held in the db and print out the record with the next date in it. Say today's date is 20/09/06, the record with the next date, say 23/09/06, should be printed out. How can I do this easily. I am very new to this, and can't seem to get it right.

View Replies !
How I Could Compare Two Dates To Find The Number Of Days That Seperate Them.
I was wondering how I could compare two dates to find the number of days that seperate them. For instance, after a user signs up to my website, they would see a specific message for only a week. Obviously this is easy if they signed up on the 14th and today is the 16th, but what about if they signed up on the 29th, then I need to figure out for the next month.

View Replies !
Strtotime And Dates Long Long Ago ...
while making an encyclopdie on my hometown (dutch,
http://www.kgv.nl/index.php?id=610) i am trying to use dates prior to
1970. birthdates in, let's say, 1615.

i'm getting errors while working with these dates, for example when i am
calculating which day of the week it is. the dates are stored in a
mysql database.

is there another way to convert stringtype dates to work with?

View Replies !
The Old "compare Dates" Thing
I've been looking all over the place for a compare dates script that will work in my instance. I can't find one. This shouldn't be difficult, unless you're like me and get nose bleeds when trying to do anything related to numbers. I'm having a hell of a time wrapping my head around strtotime() and the epoch. Plus, I can't see straight right now

Here's what I want to do.

1. user joins.
2. thank you email is sent
3. if account is not activated within 3 days, send a reminder email

// i think it's like this
$today
$date_joined
$cutoff_date = ($today + 30 days)
if($date_joined >= ($cutoff_date - 3 days)) {
//do something
}
1. user joins
2. user has 30 days to try account
3. 3 days before account is to be deleted, reminder email is sent

// again, I'm "thinking"
$date_joined
$reminder_date = ($today + 3 days)
if($date_joined >= $reminder_date) {
do something
}

View Replies !
Offering Dates And Booked Dates In A Table As DATE Datatype Using MYSQL.
Availability dates in offering dates except booked dates. For Example: Offering dates are :

01-09-2005 to 27-09-2005
01-11-2005 to 30-11-2005

Booked dates are :

10-09-2005 to 23-09-2005

Availability dates should be

01-09-2005 to 09-09-2005
24-09-2005 to 27-09-2005
01-11-2005 to 30-11-2005

I am storing offering dates and booked dates in a table as DATE datatype using MYSQL.
So, I want the above mentioned availability dates as a result.

View Replies !
Dates In Range Falling Between Existing Dates
The latest quandry I have is that I need to:

a: check whether any dates in a date range entered by a client in a form (datefrom, dateto) conflict with any existing date ranges already in the database.

-this is a check to see whether the dates that a customer is trying to book are not already booked-
Obviously its easy to get the numbers out of the database (i.e. 28/12/2006 or whatever format) and from the form but how to I convert this 'range' actually into a range I can loop through that will return true if any of the dates are the same (i.e. already booked)?

b: is similar in that I want to check how many of the clients entered dates fall into the pre assigned high, mid and low season ranges in the database and multiply each of those days by the corresponding price.

View Replies !
Using Strtotime()
Lets say I have a variable $time = 'Apr 30 2007 7:00AM'. Is there a function that I can use or a way of using the strtotime function to see if that variable $time is between the hours of 7am and 7pm?

View Replies !
Strtotime
I am trying to compare 2 dates, so that if a post is older that 90 days the user is not allowed to edit it.

i am storing the post date in mysql in datetime field (2007-04-21 10:53:07). My question is how to user strtotime function to compare the NOW() date&time with the stored one, so if greater that 90 days return true.

View Replies !
A Bug With Strtotime
Something seems to be wrong with the strtotime function in PHP5. I've created a staff resourcing database, which is used to assign staff to projects on a weekly basis. The database stores assignments against a week ending date, which is derived using: PHP Code:

$week = date('Y-m-d',strtotime('Sunday'))

This works fine, $week is set to the current week ending date (Sunday) using this. However, I also create $nextweek and $lastweek using: PHP Code:

$nextweek = date('Y-m-d',strtotime('next sunday',strtotime($week)));
$lastweek = date('Y-m-d',strtotime('last sunday',strtotime($week)));

This has also been working fine, until we got to week ending Sunday 30th October. For some reason, when $week = 2005-10-30, $nextweek becomes 2005-10-05, which is a Saturday. I've tried replacing the 'next Sunday' with '+7 days', but this returns the same date. Is this a bug? Am I missing something?

View Replies !
Strtotime &
I've got a question and was hoping someone could offer some assistance. I've got this simple line in a test file. PHP Code:

echo date("Y-m-d", strtotime("next Monday"));

Here's my results using different versions of PHP:PHP 4.4.7: 2007-11-04PHP 5.1.2: 2007-11-05PHP 5.2.3: 2007-11-05
Todays date is November 03, 2007 (2007-11-03).

View Replies !
Strtotime()
<?php
$current = date ("F", strtotime("now"));

$next = date("F", strtotime("next month")); //or try "+1 month"

echo $current.'...'.$next;
?>

View Replies !
Problem With Strtotime
I am stucked with strtotime to convert date earlier than 1970 into time.
Is there any other way to convert older dates between 1900-1970 into time?

View Replies !
Strtotime 30mins Ago
How can I use strtotime to return the time 30 mins ago, for example:

date("ymd H:i:s",strtotime("-30 minutes"));

View Replies !
StrToTime () Issue
I'm using strtotime to get the timestamp for midnight. I have a statistics
script for my pagecounter that displays hits since midnight.
I also display the number of hours and minutes passed since midnight.

$start = strtotime ('today 00:00');
$timepassed = date ('H:i', time () - $start);

The weird part is at 11.30 AM it says 12 hrs and 30 minutes have passed.
I tried adding GMT+1 like so: $start = strtotime ('today 00:00 GMT+1');
because I suspect the fact I'm in Holland is the reason for the
miscalculation.
But this format is refused by strtotime. (-1)
Does anyone know
a) whether this is indeed the problem, and
b) how to fix it. Preferrably not alone for me here, but in suc a way anyone
around the globe would have a correctly working script if they'd use mine.

The php page for strtotime pointed me to a link at gnu.org where the syntax
for it apparantly is listed, but I get a no such page error.

View Replies !
Strtotime And Cron
I've got a db of events which have dates attached to them which have been created using strtotime().  They don't have any time.. just the date.  I've got a script which gets today's date using strtotime("today").  I use this as a comparison to find events which happen today.  This works fine when I call the script from a URL, however when I called the php file from a cron job... the strtotime("today") creates values which are different each time.

Are there any thoughts on what could be causing this?  Firstly, I was wondering if the cron job was somehow using a different timezone to me (I'm On GMT).  How do I explicitly tell php to use GMT.. .but then again.. this should matter too much, because I jsut want to date not the time!  It also wouldn't account for the changing values of strtotime("today").

Just out of interest, does php4 and php5 handle strtotime("today") differently?  I'm just wondering if cron is using the correct version of php?

View Replies !
Strtotime Question?
I have a string that looks like (a series of them)

1 Sep 2007 21:06:11
2 Sep 2007 13:45:31
2 Sep 2007 13:45:31
3 Sep 2007 01:40:42

and I want to go strto time on it any ideas its return -1 right now so I know somethings wrong.

View Replies !
Date Strtotime
i am trying to right a date into the mysql database but when i get the date from the html form and do strtotime on it it goes to an invalid date (by this i mean it is not the date i entered in the html form so for example 22-06-2007 changes to 28-11-2027).

View Replies !
Remove 0 From Strtotime?
Like every other blog in the world, I have mine displaying the date and time of each entry. Right now this is what I'm using:

echo date('h:ia', strtotime($r[date]));

My latest entry's time is displayed as 07:56pm. How do I remove the 0 when the hour is a single digit?

View Replies !
Strtotime(date('m/d/Y'))
does the following code give the correct time:?strtotime(date('m/d/Y')) or do I need to use : strtotime(date('d/m/Y'))?

I tried to find out which way the month and day work, but can't seem to find anything that will tell me.

View Replies !
Strtotime() Pre-1970
if I code

$birth = strtotime(&#391; April 1950');

then $birth = -1, I guess that this is because time "began" on 1st Jan, 1970. (although I seem to remember a few good times before that). So, what's the easiest way to find out how many days old I am (exactly, please, not just taking 1 April 1970 and adding 20 *365, which does not account for leap years?

View Replies !
Strtotime Failure
I don't know how I should input date + time into a strtotime function (i'm a total noob) so I tested this:

<?
$d=01;
$M=01;
$y=1970;
$h=01;
$m=01;
$s=01;
echo "$d $M $y $h:$m:$s";
echo strtotime("$d $M $y $h:$m:$s");
?>

I get as echo strtotime '-1', wich means the strtotime has a failure. Can anybody explain me why? Or can anybody tell me how I can make a strtotime function that puts a timestamp in the database depending on the date and time inserted in a textbox? (one textbox or one textbox to insert the day, another to insert the year,...) I should be able to change a format like (for example) this : 01-02-1990 00:00:00 (midnight) into a timestamp. so dd-mm-yyyy hh:mm:ss (or something else just to make it work)I'm clueless.

View Replies !
Strtotime With Days
On this - "next Thursday" is that next thursday or the next thursday ie: on wed will it show tomorrows time or the next week? PHP Code:

<?php
echo strtotime("now");
$timestamp = strtotime("now");
echo "  ";
$str = date('l dS of F Y h:i:s A', $timestamp);
echo $str;
?>

<p>

<?php
echo strtotime("next Thursday"), "";
$timestamp = strtotime("next Thursday");
echo "  ";
$str = date('l dS of F Y h:i:s A', $timestamp);
echo $str;

View Replies !
Strtotime Problem
How do I find the number of seconds from a certain date to the current? I have logged in my database a completion date within the past year and I want to figure out how many seconds it has been since the completion date until now. I know the strtotime command is fairly versatile and I have tried the following without the right conclusion: PHP Code:

strtotime("since ".$completion_date);
//and
strtotime("from ".$completion_date);

What do I need to do to fix this?

View Replies !
Why Doesn't Strtotime('') Return -1
instead of the warning message:
strtotime(): Called with empty time parameter in ...

Any good reason?

View Replies !
Strtotime Busted
$thing = "2005-10-01";
$storedDate = date("z",strtotime($thing));
echo $storedDate;

it just alwats returns today's date, ive tried it on a php5 server and it worked fine however on the server I need this one it is PHP4.2.

View Replies !
Strtotime Missing A Zero In Minutes
I am working with strtotime. The following problem occurs when using this function:

View Replies !
Strtotime - Setting From Present
I am having trouble setting the strtotime function to echo 'Y-m-d' on any day from 1 - 24 months past.

I have attempted the following from links that call to different ranges of dates; 6 months, 9 months, 12 months, etc. -- from present time:

My SQL is set up as follows:
WHERE Date between 'pastDATE' and CURDATE()
pastDATE = $HTTP_GET_VARS["getDATE"]

<a href="oldies.php?getDATE=<? echo strtotime ("-6 months ago"); ?>"> 6 MONTHS OLD </a>

How can I echo the strtotime as "Y-m-d"?

View Replies !
Negative Number In Strtotime
What does a negative number in strtotime mean? I looked in the manual, couldn't figure it out.

strtotime('-1 month')

View Replies !
Strange Strtotime() Behavior
I'm trying to use the strtotime() function to manage sessions. But I
get the following

<?php
print(time() . " - " . strtotime("+1 hour"));
?>

outputs:

1097380666 - 1097308800

Strange strtotime("+1 hour") produced a time stamp less than the
current time. It also never changes. In other words strtotime("+1
hour") always results in the time stamp 1097308800.

I have also tried strtotime("+1 hour", time()) with the same result

Is this correct, have I misunderstood the strtotime() function?

I'm running Gentoo with kernal 2.6.8.1, php 5.0.1, apache2

View Replies !
Displaying A Date With Strtotime
I have successfully used strtotime to format the date on a webpage that is
pulled form a MySQL database in the form yyyy-mm-dd.

However, in another part of the webpage, I have to insert another date that
may contain a NULL entry in the database. If I use strtotime to format this
then it enters the current date, whereas I want it left blank.

View Replies !
Strtotime And A Very Mysterious Date
Namely the thirteenth of December 1901, 12:45:52, Pacific Time.

All dates later than this passed in format "yyyy-mm-dd hh:mm:ss" to the
strtotime function return the correct unix timestamp value (as can be
verified by passing it back to date()).

If a date earlier than 1901-12-13 12:45:52 is used, it returns an error.
I tried this for a while to find the exact cut-off point, and this is it.

Any reason - possibly a limitation of the integer value that is used? I
didn't find this documented anywhere...

View Replies !
Strtotime - Use Abbreviations For Week
I'm pretty sure I used to be able to use abbreviations for week (w), days
(d), etc in strtotime (e.g. strtotime("-3d") = 3 days ago), but now it
doesn't work as expected unless I specifiy the whole word ("-3 days"). Has
anyone else come across this ?

View Replies !
Use Strtotime To Convert A Date
I am trying to use strtotime to convert a date, gathered from a database, and add 21 days to the date. Example:

Date from MySQL record is 2007-01-01 I need it to be echoed to the browser as 2007-01-22.

Here is what I have now but it just outputs the database date without adding the 21 days.

$requested = date('F jS, Y', strtotime($row['letter_requested'])); //Convert to letter requested date
$sendBy = strtotime($requested, '+21 day');
echo $sendBy;

View Replies !
Getting Consistent Results With Strtotime()
I am having a problem getting consistent results with strtotime().  I am taking user input from a text box, and converting it into a timestamp in GMT.  Here is the code (I'm using PHP 4.4.4): Code:

View Replies !
Strtotime - Data That's Output From My Db
I have data that's output from my db in the form Sunday 9th September 2007 21:29:22.

I'm getting it by using

<?php

$timestamp= $row['timestamp'];
echo date('l jS F Y H:i:s', strtotime($timestamp));

?>

I'd like to add 19 hours to it, but have no idea how to.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved