Don Wieland schrieb:
Hi gang,

I need a bailout.

I have a fields called "sys_first_day_of_week" and the user can select one value which will be from a menu with these options:

Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday

Based on this "Preference" and TODAYS DATE, I want to calculate the first day of the week.

So if my preference is "Monday" and Today's date is 10/19/2010, I want to return a value of: 1287374400 (which is 10/18/2010)

if my preference is "Wednesday" and Today's date is 10/19/2010, I want to return a value of: 1286942400 (which is 10/13/2010)

Appreciate any help.

Don
I'm not sure: You are searching the date of the last given weekdate?

$sys_first_day_of_week: Monday => 1, ..., Saturday => 6, Sunday => 0

Try this one: date seems to be correct, but value is different, maybe different time zone?

if ( date('w') > $sys_first_day_of_week ) {
$value = mktime(0,0,0,date('n'),date('j'),date('Y')) - ( 7 + date('w') - $sys_first_day_of_week ) * 24 * 60 * 60;
}
else {
$value = mktime(0,0,0,date('n'),date('j'),date('Y')) - ( date('w') - $sys_first_day_of_week ) * 24 * 60 * 60;
}



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to