Jump to content

[SOLVED] Simple form and datetime question


danthemilk

Recommended Posts

Howdy

 

My form contains select elements for each of the following:

year

month

day

hour

minute

second

 

I need to get that POST data into a valid datetime format like this:

2009-06-19 12:15:00

 

I have tried

$mydatetime =  mktime($year, $month, $day, $hour, $minute, $second);

but when I trace $mydatetime I get nothing, and I can't insert that value into the database, which is my ultimate goal.

 

Any help with this is greatly appreciated since I'm fairly new to PHP and can't seem to get the google machine working.

 

I turned on error reporting and didn't get any error messages. Thanks for your suggestion.

 

This seems like something that would be required all the time. I have the variables for each part of the datetime object, I just need to format them as a datetime object and insert them into my database. Can someone tell me why my $starttime variable:

$starttime = mktime($hour, $minute, 00, $month, $day, $year);

gets inserted into my database as 0000-00-00 00:00:00?

 

should I be using a function other than mktime? Is there a standard method of inserting a datetime object into a database that I'm missing?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.