Welcome to WebmasterWorld Guest from 54.147.28.255

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Strtotime on different servers

     
11:29 am on May 2, 2010 (gmt 0)

New User

10+ Year Member

joined:Mar 24, 2005
posts: 36
votes: 0


Hi
Can anyone enlighten me as to why the following code:

$date = "31-12-2009";
for ($i = 1; $i <= 365; $i++) {
$newdate = strtotime ( '+1 day' , strtotime ( $date ) ) ;
$newdate = date ( 'd-m-Y' , $newdate );
$timestamp = strtotime($newdate);
echo "(",$i, ", '",$newdate,"', ",$timestamp,")<br>";
$date = $newdate ;
}


Outputs:
(1, '01-01-2010', 1262300400)
(2, '02-01-2010', 1262386800)
(3, '03-01-2010', 1262473200)
(4, '04-01-2010', 1262559600)
(5, '05-01-2010', 1262646000)......
On my local server [windows + XAMPP php ver 5.28]

but on my webhosts server it outputs:
(1, '01-06-2037', 1167260400)
(2, '29-12-2006', 2064002400)
(3, '30-05-2035', 2079558000)
(4, '26-11-2035', 1969221600)
(5, '28-05-2032', 2016226800).......
[php ver4.49]


I'm trying to populate a MYSQL database with:
[ID] -- [date] -- [timestamp]
'1' '01-06-2037' '1167260400'

So I can calculate dates
I have my site working perfectly locally but when I uploaded it nothing would work.
9:24 pm on May 2, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 4, 2001
posts: 1263
votes: 12


Have you tried uploading it to a different web server?
10:13 pm on May 2, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 12, 2005
posts:5966
votes: 0


Try this real quick:


$date = "2009-12-31";
4:07 pm on May 3, 2010 (gmt 0)

New User

10+ Year Member

joined:Mar 24, 2005
posts:36
votes: 0


IanKelley Thank you I did try it on a VPS I have and it works perfectly with and without eelixduppy suggested change.

eelixduppy Thank you I did try the change you suggested, not sure if I was quick enough but it just gives a similar munged output:

(1, '01-01-2010', 1151877600)
(2, '04-07-2006', 1261868400)
(3, '28-12-2009', 2032725600)
(4, '02-06-2034', 1198537200)
(5, '26-12-2007', 1969394400)
(6, '30-05-2032', 2079298800)
(7, '23-11-2035', 1874527200)
(8, '28-05-2029', 2015967600)
(9, '20-11-2033', 1779746400)
(10, '27-05-2026', 1984086000).......

Can anyone give me a clue as to where the problem may lie [it's a shared hosting acc with 1&1] so I can have a moan at them about it.

Thank once again.
4:27 pm on May 3, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Feb 22, 2009
posts:1396
votes: 0


Hi there Pollos,

I have just tested your code on my local host & my server, and there output is identical(correct, no jumps in dates at all), are the servers your uploading to in the same or different time zones? Just a thought there...

So from what I can see there is nothing wrong with the code, though I am dubious of reusing the $newdate var twice. A little confusing ;)

Cheers,
MRb
4:52 pm on May 3, 2010 (gmt 0)

New User

10+ Year Member

joined:Mar 24, 2005
posts: 36
votes: 0


Hi Matthew

I have two accounts with 1&1, the script works fine on my VPS running Cent I believe, with PHP Version 5.1.6

The site I'm working on is on shared hosting again with 1&1. Operating system ? PHP Version 4.4.9

$newdate, yes you are correct, in my original script it was $newday = strtotime ( '+1 day' , strtotime ( $date ) ) ;

I think I'll have to have a word with 1&1's tech dept, unless anyone has any other ideas.
5:10 pm on May 3, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Feb 22, 2009
posts:1396
votes: 0


Hi there Pollos,

Well it certainly seems to be having an effect, my host is UK based, and my laptop is in Wales! Though the time zone is the same :) At least it's not the script that's at fault.

The only thing I will add, is that my local is windows & my server is linux, and this seems to have no effect, not that it should, but just to cover that base ;)

Cheers,
MRb
5:12 pm on May 3, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 4, 2001
posts: 1263
votes: 12


Having tried it on multiple servers I think you can be pretty sure the problem is on the server itself. Definitely an issue for their tech support.
5:41 pm on May 3, 2010 (gmt 0)

New User

10+ Year Member

joined:Mar 24, 2005
posts:36
votes: 0


Thanks guys I'll drop them a e-mail and await their reply.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members