Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 07-08-06
Registered User
 
Join Date: Feb 2006
Location: Gillingham
Posts: 503
Thanks: 0
Thanked 0 Times in 0 Posts
Donk is an unknown quantity at this point
  strtotime -unexpected results

I was trying to get a list of monthends over the previous year using strtotime ("last month").

So I tried this:
PHP Code:
<?php
$montharray
=array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
foreach (
$montharray as $key=>$value){
$showdate=date("Y-m-d H:i:s"strtotime("last ".$value));
echo 
$showdate."<br>";
}
?>
I got some surprising results! I could have accepted the first day month or the last day of the previous month, but the results I got were a day before the end of the month.

Quote:
2005-12-30 00:00:00
2006-01-30 00:00:00
2006-02-27 00:00:00
2006-03-30 00:00:00
2006-04-29 00:00:00
2006-05-30 00:00:00
2006-06-29 00:00:00
2006-07-30 00:00:00
2006-08-30 00:00:00
2006-09-29 00:00:00
2006-10-30 00:00:00
2006-11-29 00:00:00
The most difficult to understand is from september onwards! PHP regards last september as 29/09/2006?????
__________________
They came for my 404 and I said nothing
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-08-06
Tom Tom is offline
Registered User
 
Join Date: May 2005
Posts: 199
Thanks: 0
Thanked 0 Times in 0 Posts
Tom is an unknown quantity at this point
Isn't it just one day short on each month?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-08-06
drivetowin's Avatar
Driving to win
 
Join Date: Aug 2003
Location: If I'm not at home, I'm in hospital
Posts: 7,363
Thanks: 5
Thanked 8 Times in 5 Posts
drivetowin seems to know their stuff
The problem is because strtotime treats every month as being 30 days.

It is a known bug in strtotime.

You are also misinterpreting what it means by last - it does not mean the last day of the month, it means previous - i.e last monday = monday last week.
__________________
Never argue with idiots. They just drag you down to their level and then beat you with their experience.

If ignorance is bliss then some of the people I know must be orgasmic.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-08-06
Registered User
 
Join Date: Feb 2006
Location: Gillingham
Posts: 503
Thanks: 0
Thanked 0 Times in 0 Posts
Donk is an unknown quantity at this point
Hi keith

I understand the concept of last month.
But "last Sep" gives 2006-09-29 00:00:00 I would say that is this or even next september I would have expected 2005-09-29 to be consistent.


Bob
__________________
They came for my 404 and I said nothing
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #5 (permalink)  
Old 07-08-06
drivetowin's Avatar
Driving to win
 
Join Date: Aug 2003
Location: If I'm not at home, I'm in hospital
Posts: 7,363
Thanks: 5
Thanked 8 Times in 5 Posts
drivetowin seems to know their stuff
Hi Bob

That's true - looks like it's a function with more than a few quirks!!
__________________
Never argue with idiots. They just drag you down to their level and then beat you with their experience.

If ignorance is bliss then some of the people I know must be orgasmic.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Google Sued for Low Rankings Another Media The Affiliate Marketing Lounge 66 26-04-07 11:57 PM
google to expand into CPA betterHalf The Affiliate Marketing Lounge 23 30-06-06 12:53 PM
DGM results phildarv DGM Affiliates 3 13-03-06 08:41 PM
Is google rotating results? will 68 Organic Google Search Optimisation 3 06-04-05 12:42 PM
ASOS Audit Results jesss1 The Affiliate Marketing Lounge 13 27-02-04 11:14 AM


Affiliate Marketing RSS Feeds - Contact Us - Affiliate Marketing - Archive - Privacy Statement - Top

Content Relevant URLs by vBSEO 3.2.0 RC7