Jump to content

date from url to database


BluwAngel

Recommended Posts

I won't creata the code for you, but I'll help you wrap your head around things.

 

There's something I need to understand from you first.  You said you can grab the values from the url, that I'm assuming looks like this:

http://example.com/?day=1&month=3&year=2012

 

So using $_GET you can grab these values which you said you already know how to do.

$month = $_GET['month'];
$day = $_GET['day'];
$year = $_GET['year'];
// Now you need to combine into one value, easy
$date = $month . $day . $year;

 

So what exactly do you need after that?

Do you want to convert the date into a timestamp? I need some clarity.

Well, considering that mysql's DATE format is, YYYY-MM-DD, and if your url is http://example.com/?day=01&m=03&year=2012

Then you shouldn't have any issues.

 

You would combine your required get values into one variable:

$date_to_enter_into_database = $_GET['year'] . '-' . $_GET['month'] . '-' . $_GET['day'];

 

And add it into your database. That way it is formatted for mysql's DATE function.

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.