Page 1 of 1

Calendar

Posted: Wed Aug 30, 2006 6:18 am
by Supper Baby
Hello everyone :) ,

that's my function :

Code: Select all

/*
* That function take unix time and generate human form for the given time.
* If there's no old value ( no given time ) then use the corrent unix time!
*/
        Function DateForm( $unix )
        {
                // If we don't have unix time get today unix time
                $unix = ( $unix == 0 OR $unix == '' ) ? time() : $unix;
                
                // Convert Unix to human!
                $tmp    = gmdate( 'j,n,Y', $unix );
                list( $day, $month, $year ) = explode( ',', $tmp );

                # Create Day List
                $html .= "<select name='day'>";
                for ( $i=1; $i <= 31 ; $i++ )
                {
                        if ( $i == $day )
                        {
                                $html .= "<option selected value='$i'>$i</option>";
                        }
                        else
                        {
                                $html .= "<option value='$i'>$i</option>";
                        }
                }
                $html .= "</select>";


                # Create Month List
                $html .= "<select name='month'>";
                for ( $i=0; $i < 12 ; $i++ )
                {
                        // Convert Monthe from number to text
                        // Why +1 ? because month number 1 not Jan it's Dec
                        $m1 = mktime(0, 0, 0, $i+1, 0, 0);
                        $m = date( 'M', $m1 );
                        if ( $i == $month )
                        {
                                $html .= "<option selected value='$X'>$m</option>";
                        }
                        else
                        {
                                $html .= "<option value='$X'>$m</option>";
                        }
                }
                $html .= "</select>";
                
                $i = 5;
                # Create Year List. Start from 2005 to 2015
                $html .= "<select name='year'>";
                for ( $i=2006; $i <= 2015 ; $i++ )
                {
                        if ( $y == $year )
                        {
                                $html .= "<option selected value='$i'>$i</option>";
                        }
                        else
                        {
                                $html .= "<option value='$i'>$i</option>";
                        }
                }
                $html .= "</select>";

                Return $html;
        }
User should chose(add/edit) the dat from that form.

then I recive from details :

Code: Select all

// Human to unix
$data = mktime( 0, 0, 0, intval( $_POST['month'] ), (intval( $_POST['day'] )), intval( $_POST['year'] ) );
but it doesn't work.

I get ( day -1 ) and the month change in a wonder way.

there's some thing wrong with this algorithm. I didn't get the exact time which I chose.

Any advise please ?
:roll:

Posted: Wed Aug 30, 2006 6:51 am
by Ollie Saunders
use

Code: Select all

date()
and friends instead.