Jump to content

date from url to database


BluwAngel

Recommended Posts

heres the problem

i have 3 things in url bar

$day

$month

$year

(its important it stays 3 variables in url)

 

i know how to get them but what i need is convert these 3 into 1 value and store it to DATE(it would be good to be date type for later use) type in mysql

 

any ideas?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.