if i have a given date so how can i find in what date sun and sat comming ... ?
i store 0 for sat and 6 for sun in database.

Member Avatar for diafol

Get the day from the current date:

$current = date('w');
$nextSat = ($current == 6) ? 7 : 6 - $current;
$nextSun = ($current == 6) ? 1 : $nextSat + 1;
//a routine for adding days, eg for Sat:
$dateSat = date_create(date('Y-m-d'));
date_add($dateSat, date_interval_create_from_date_string("$nextSat days"));
echo date_format($dateSat, 'Y-m-d');

first you have to separate the date

then have this code

$weekday = date("l", mktime(0,0,0,$month,$day,$year));
echo $weekday;

l will return the what woul be the week day of that particular date

then
have a condition on what you want,....

or you can handle it in database...
see this example hope it will help http://astirex.blogspot.com/2012/05/mssql-function-returns-week-day.html
i use to handle using database ............................

thanx all for reply
i am little bit confuse here..
basically what i want to do it ... if user set a task let says on 2012-june-2 so i have a form that is already sumiteed and data has been store to mysql it has two fields sat , sun ...if user set this to mon...tue wed.. etc .. so i have to check from above date when mon... or what ever he set in submitted form...i want to store that final date by calculating to mysql fields...

so $final_day_sat_move store calulated next date to mysql but not working above...
$date_plus_dueoff =2012-june-2

$weekday = date('D', strtotime($date_plus_dueoff));

                            $nextTues = strtotime('next tuesday');
                            $tuesday=date("Y-m-d",$nextTues);

                            $daydiff = floor((strtotime($tuesday) - strtotime($date_plus_dueoff) ) / 86400 );
                            //echo $daydiff;
                            //exit;
                            $final_day_sat_move=date('Y-m-d H:i:s', strtotime($date_plus_dueoff. ' + '.$daydiff.' days'));
Member Avatar for diafol

Do not use seconds for date calculations - they can fail spectacularly with leap years and daylight saving features.

Unfortunately, I do not undertand your requirements:

if user set a task let says on 2012-june-2 so i have a form that is already sumiteed and data has been store to mysql it has two fields sat , sun ...if user set this to mon...tue wed.. etc .. so i have to check from above date when mon... or what ever he set in submitted form...i want to store that final date by calculating to mysql fields...

This makes little sense to me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.