Hello everybody,

I hope you all have a nice day, mines not that good 'cause i have encountered a 
strange problem.

i have a few functions to work with dates. they are all very simple, a few 
lines of code.
this first one does just gives you the monday of the current week:

function get_monday($date) {
                
                $input_date = strtotime($date);
                $date_array = date_parse(date('r',$input_date));
                $get_sunday = 7 - $date_array['relative']['weekday'];
                
                $day_label = date("D, d.m.y",mktime(0, 0, 0, date("m")  , 
date("d")+$get_sunday, date("Y")));
                $new_day_label = strtotime($day_label);
                $monday = date("D, d.m.y",mktime(0, 0, 0, 
date("m",$new_day_label)  , date("d",$new_day_label)-6, 
date("Y",$new_day_label)));
                
                return($monday);
                
                }

now for testing purpose we say today is friday, 11.07.2008, this function 
returns correct Mon, 07.07.08.
now the problems lies in the second function or more in strtotime.
this second function just takes the inputed date and does some formating so it 
will fit into
the mysql db or query.

function get_mysql_date($date) {
                
                $old_date = strtotime($date);
                $new_date = date("Y-m-d",$old_date);

                return($new_date);
        }

But now the strange thing happening is, this function outputs '2008-07-14' 
which is monday of the next week.
now i think the problems lies somewhere in strtotime(), cause if i do this:

$dateForTable = $date_class->get_monday($today);
$dateTest =strtotime($dateForTable);
$dateTest2 =date('r',$yousuck);

it will also output 'Mon, 14 Jul 2008 07:07:08 +0200'.

i think strtotime() takes just the first part 'Mon' and looks what date the 
next monday is.
i'm realtivly new to php so any help solving this problem will be greatly 
appreciated.

thanks alot to all.

greetings from switzerland
------------------------ 
Fabian Frei 
[EMAIL PROTECTED] 
fon: 071-390 04 35 
mobile: 079-733 45 27 
------------------------

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

Reply via email to