473,586 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Slow performance using strtotime on prior 1970 dates

cla
I'm using this code on an application to track football schedules:
----
$season = '2005';
$basedate = strtotime('this friday', strtotime('31 August '.$season));

for($d=0;$d<=31 ;$d++) {
$d2=strtotime(" +".$d." day",$basedate) ;
echo(date('m d Y',$d2)."\n");
}
----
The purpose is to find the first Friday on or after Aug. 31 in a given
year. Plug '2005' into $season, and it flies through. Plug in
'1905', however, and each step in the for loop takes about .5 sec.
I'm running this code in PHP 5.2.1. Any ideas?

Sep 14 '07 #1
5 2506
Well the fact is 1970 was when the Unix Epoch started, so any dates
prior to that date are much more slower. I don't know why, but try on
a Windows machine and see if the same happens. Probably it's just on
*nix systems.

Sep 14 '07 #2
On Sep 14, 3:22 pm, cla <cla...@gmail.c omwrote:
I'm using this code on an application to track football schedules:
----
$season = '2005';
$basedate = strtotime('this friday', strtotime('31 August '.$season));

for($d=0;$d<=31 ;$d++) {
$d2=strtotime(" +".$d." day",$basedate) ;
echo(date('m d Y',$d2)."\n");}

----
The purpose is to find the first Friday on or after Aug. 31 in a given
year. Plug '2005' into $season, and it flies through. Plug in
'1905', however, and each step in the for loop takes about .5 sec.
I'm running this code in PHP 5.2.1. Any ideas?
If all you want to do is find the first Friday on or after August 31
why do you need the loop?

Sep 14 '07 #3
cla
On Sep 14, 12:59 pm, ZeldorBlat <zeldorb...@gma il.comwrote:
On Sep 14, 3:22 pm, cla <cla...@gmail.c omwrote:
I'm using this code on an application to track football schedules:
----
$season = '2005';
$basedate = strtotime('this friday', strtotime('31 August '.$season));
for($d=0;$d<=31 ;$d++) {
$d2=strtotime(" +".$d." day",$basedate) ;
echo(date('m d Y',$d2)."\n");}
----
The purpose is to find the first Friday on or after Aug. 31 in a given
year. Plug '2005' into $season, and it flies through. Plug in
'1905', however, and each step in the for loop takes about .5 sec.
I'm running this code in PHP 5.2.1. Any ideas?

If all you want to do is find the first Friday on or after August 31
why do you need the loop?
The loop's more for a demo. In the live app, there's a drop down list
of possible dates within a given week of a season. The first Friday
is just the starting point from which all subsequent dates are
referenced.

Sep 14 '07 #4
cla
On Sep 14, 12:24 pm, RageARC <rage...@gmail. comwrote:
Well the fact is 1970 was when the Unix Epoch started, so any dates
prior to that date are much more slower. I don't know why, but try on
a Windows machine and see if the same happens. Probably it's just on
*nix systems.
Made a quick test on a Windows box, and the performance seems to be
about the same.

Sep 14 '07 #5
Well, I searched, and I found the following:

The valid range of a timestamp is typically from Fri, 13 Dec 1901
20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates
that correspond to the minimum and maximum values for a 32-bit signed
integer.) Additionally, not all platforms support negative timestamps,
therefore your date range may be limited to no earlier than the Unix
epoch. This means that e.g. dates prior to Jan 1, 1970 will not work
on Windows, some Linux distributions, and a few other operating
systems. PHP 5.1.0 and newer versions overcome this limitation though.

Yep, 5.1.0 overcomes this limitation, but at a much slower pace.

Sep 14 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3093
by: ruud habets | last post by:
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...
1
2995
by: sylvian stone | last post by:
Hi, I've used standard date functions in the past, but need to create something a little different, as I am working on an investment calculator. What I need to do is validate two dates, and check for a complete years. And a complete year is from day 1 until the proceeding day the following year. A couple of examples:
4
2720
by: psql-mail | last post by:
I am running a SELECT to get all tuples within a given date range. This query is much slwoer than i expected - am i missing something? I have a table 'meta' with a column 'in_date' of type timestamp(0), i am trying to select all records within a given date range. I have an index on 'in_date' and I also have an index on date(in_date). The...
7
15479
by: Adrian | last post by:
I hit on this problem converting a VB.NET insurance application to C#. Age next birthday calculated from date of birth is often needed in insurance premium calculations. Originally done using DateDiff in VB.NET which is only available in C# if you don't mind linking in Microsoft.VisualBasic.dll to your C# application. I wanted to avoid this...
2
18314
by: ameshkin | last post by:
Hi GUys, Im 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. Basically, if the last comment is newer than the last user login, then I need for a message to pop up and say New Comments. If not, then no new comments. The area of this code which...
2
2987
by: Baron Samedi | last post by:
if I code $birth = strtotime('1 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...
9
19128
by: Emin | last post by:
Dear Experts, I have a fairly simple query in which adding a where clause slows things down by at least a factor of 100. The following is the slow version of the query ------------------------- SELECT * FROM ( Select x.event_date From x FULL OUTER JOIN y ON x.event_date = y.event_date
6
38919
by: Brandon | last post by:
I'm using PHP with MySQL 4.x and was having trouble converting a datetime from MySQL into a formatted string until I ran across this solution that converts a YYYY-MM-DD HH:MM:SS string into a Unix-style timestamp and then formats it. $timestamp = "2005-04-06 15:43:34"; $time = strtotime($timestamp); print date('Y-m-d \a\t H:i',...
9
1816
by: Erwin Moller | last post by:
Hi group, I have been using strtotime a lot in my code. I wonder if I made a mistake in my thinking. :-/ Here follows a stripped down example. consider some dates: $date1 = "2008-02-23"; $date2 = "2008-02-23"; (They are the same)
0
7841
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8204
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3838
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1184
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.