Welcome Guest, Not a member yet? Register   Sign In
timestamp woes
#1

[eluser]jbads[/eluser]
Hi, I'm having trouble with some dates and hopefully someone could shed some light.

On my form users can enter 2 dates: the date that they would like their advertisment to become live on my website and a date for the event they are advertising.

This is the code in my controller for converting the input dates to timestamps:
Code:
$e_date        =     $this->input->post('event_date_day').'/'.$this->input->post('event_date_month').'/'.$this->input->post('event_date_year');
                $a_date        =    $this->input->post('active_date_day').'/'.$this->input->post('active_date_month').'/'.$this->input->post('active_date_year');    
                
                
                //$date is for activation date
                $date                    =            explode('/', $a_date);
                $a_timestamp            =            mktime(00,00,01,$date[1],$date[0],$date[2]);
                
                //x_date is for event date
                $x_date                    =            explode('/', $e_date);
                $e_timestamp            =            mktime(00,00,01,$x_date[1],$x_date[0],$x_date[2]);

If I echo out these variables. I get this:
Code:
print_r($a_date);
                print_r($date);
                print_r($a_timestamp);
                print_r($e_date);
                print_r($x_date);
                print_r($e_timestamp);

Quote:25/09/08 Array ( [0] => 25 [1] => 09 [2] => 08 ) 1222257601 04/12/08 Array ( [0] => 04 [1] => 12 [2] => 08 ) 1228302001

I would like to create a timestamp for 1 second past 12am on the date the user entered.
However when I put the generated timestamps into a timestamp converter I get
Wed, 24 Sep 2008 12:00:01 GMT (should be 25 sep 2008 00:00:01) and
Wed, 03 Dec 2008 11:00:01 GMT (should be 04 dec 2008 00:00:01)
#2

[eluser]Aken[/eluser]
Look into this PHP function to set your timezone: date_default_timezone_set()




Theme © iAndrew 2016 - Forum software by © MyBB