473,385 Members | 1,337 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

PHP strtotime wrong on March 2009?

dlite922
1,584 Expert 1GB
I'm not sure if it's a bug or maybe some weird way strtotime() works, but I need dates for

1. Second Sunday of March
2. First Sunday of November

for any given year (mostly current year).

This
Expand|Select|Wrap|Line Numbers
  1.  
  2. echo "SPRING DST = " , date('M d Y ',strtotime("Second Sunday March")) , 
  3.       "<br>FALL DST = " , date('M d Y ',strtotime("First Sunday November"));
  4.  
  5.  
  6.  
Outputs:
Expand|Select|Wrap|Line Numbers
  1. SPRING DST = Apr 05 2009
  2. FALL DST = Nov 29 2009 
  3.  
  4. //expected Output
  5. SPRING DST = Mar 08 2009
  6. FALL DST = Nov 01 2009 
  7.  
I tried other input variations and got other false outputs.

What gives?


Dan
Jul 28 '09 #1
1 2404
dlite922
1,584 Expert 1GB
Well, I finally stumbled on something that gives me that.

Here you go:


Expand|Select|Wrap|Line Numbers
  1. echo "SPRING DST = " , date('M d Y ',strtotime("March 2nd Sunday")) , 
  2.       "<br>FALL DST = " , date('M d Y ',strtotime("November 1st Sunday"));
  3.  
  4. //outputs:
  5. SPRING DST = Mar 08 2009
  6. FALL DST = Nov 01 2009 
  7.  
Hope that helped you,



Dan
Jul 28 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Pjotr Wedersteers | last post by:
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...
3
by: Dawid Szałęga | last post by:
Hi, I do something like this: $month = date('m', strtotime('2004-09-30 +5 months')) This give me 03 (March), but 09 (September) + 5 months should give me 02 (February) It's bug or I thing...
1
by: peabody | last post by:
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
7
by: Rithish | last post by:
Hello. I noticed a strange thing while using strtotime() and date() functions in combination to generate from MySQL into a readable format. By default, the MySQL date field will be 0000-00-00...
1
by: Allen Maki | last post by:
/* I am trying to practice multidimensional array in a managed class using dynamical allocation. If I tried to compile the following codes, I would get the under mentioned c2440 error...
2
cassbiz
by: cassbiz | last post by:
I am using strtotime and I have read up on some examples and am getting the wrong output, it jumps by several days instead of one day at a time. Ultimately what I am trying to accomplish is to set...
5
by: Chris | last post by:
I am trying to output Monday of the current week i.e. if Monday is the 8th I want to display 'Monday 8th' for any date between Monday 8-14th. I would appreciate any help, the code below is...
9
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";...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.