This should be easy but I’m having trouble… In PHP how can I echo out a select drop down box that defaults to the current month and has options for 8 months prior (even if it goes in the last year). For example, for this month it would default to June and end at November. Answer Alternative for “custom” month
Tag: date
PHP get number of week for month
So I have a script that returns the number of weeks in a particular month and year. How can I take a specific day from that month and determine if it is part of week 1,2,3,4 or 5 of that month? Answer The most frustrating thing I have ever tried to get working – but here it is!
PHP: Adding months to a date, while not exceeding the last day of the month
Looking to create a function that will do this in PHP. I need to add a number of months to a date, but not exceed the last day of the month in doing so. For example: Add 1 month to January (1-…
MySQL: dates before 1970
I’m working on a church site which has many events before 1970, these events starts from 1001 to today, how can I store the dates in MySQL? This works fine only for dates after 1970, how can I store dates before this year? What kind of datatype should I have in MySQL? Now I’ve set my column to date type
How do I get next month date from today’s date and insert it in my database?
I have two columns in my db: start_date and end_date, which are both DATE types. My code is updating the dates as follows: What is the best way to make $end_date equal to $start_date + one month? For example, 2000-10-01 would become 2000-11-01. Answer You can use PHP’s strtotime() function: Just note that +1 month is not always calculated intuitively.
Adding days to $Date in PHP
I have a date returned as part of a mySQL query in the form 2010-09-17 I would like to set the variables $Date2 to $Date5 as follows: $Date2 = $Date + 1 $Date3 = $Date + 2 etc.. so that it returns 2010-09-18, 2010-09-19 etc… I have tried but this gives me the date BEFORE $Date. What is the correct
I have 2 dates in PHP, how can I run a foreach loop to go through all of those days?
I’m starting with a date 2010-05-01 and ending with 2010-05-10. How can I iterate through all of those dates in PHP?
Calculate total seconds in PHP DateInterval
What is the best way to calculate the total number of seconds between two dates? So far, I’ve tried something along the lines of: However, the days property of the DateInterval object seems to be broken in the current PHP5.3 build (at least on Windows, it always returns the same 6015 value). I also attempted to do it in a
Set start and end date for last 30 days ending today
I need to generate two dates in the format YYYY-MM-DD example: 2010-06-09 The end date should be today and start date should be today – 30 days. How can I generate these 2 dates in the above format?
Round minute down to nearest quarter hour
I need to round times down to the nearest quarter hour in PHP. The times are being pulled from a MySQL database from a datetime column and formatted like 2010-03-18 10:50:00. Example: 10:50 needs …