Skip to content
Advertisement

Tag: date

PHP loop through months array

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

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!

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

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

Advertisement