Forum Moderators: coopster

Message Too Old, No Replies

date calculation

         

aanton05

10:28 pm on Jan 22, 2006 (gmt 0)

10+ Year Member



hello. i am trying to write a script that will run automatically at the end of each month via cron.

the script is supposed to query the table clients of the database. the table clients contains the field start_date. the script has to determine if the start_date is before or after the 15th of the month the client signed up.

for example:

if a client signs up jan. 10, he will start getting paid interest on feb 28(end of the month) for the month of feb.

however if a client gets in jan. 18(therefore after jan. 15), he will start getting paid interest on march 31 for the month of march.

so if the script determines that the start_date for a client is before the 15th of the month, the script needs to determine the date of the last day of the next month.

if the script determines that the start_date for a client is after the 15th of the month, the script needs to determine the date of the last day of the month after the next month.

could somebody please help? thanks.

aanton05

1:05 am on Jan 23, 2006 (gmt 0)

10+ Year Member



how do i find out if a given date i.e. 2005-11-21 has already passed? thanks.

adb64

7:45 am on Jan 23, 2006 (gmt 0)

10+ Year Member



You may want to take a look at the PHP function strtotime [php.net] to get the unix timestamp for a given date. The current time can be retrieved with time [php.net] or date [php.net].