PDA

View Full Version : Jason's Date Input Calendar Help Required



cruzier
01-29-2014, 02:13 PM
Hi,

I am attempting to implement Jason's Date Input Calendar into my website for searching availability. However, although on the front end the calendar is displayed as three input/select boxes, it actually sends the date variable as date=26-01-2014 instead of day=26&month=01&year-2014.

Is there anyway of modifying the code to get this to work this way?

Many thanks

Chris

jscheuer1
01-29-2014, 02:59 PM
Please post about Dynamic Drive Scripts in the Dynamic Drive Scripts Help section here where I've moved this thread, and:

Warning: Please include a link to the DD script(s) in question in your post. See this post (http://www.dynamicdrive.com/forums/showpost.php?p=7) for more information.

That said, if the back end is PHP, it would probably be easier to just parse the given value. BTW it's not 26-01-2014, it's 26-JAN-2014.

For instance, you can get a UNIX timestamp in PHP like so:


strtotime('26-JAN-2014')

cruzier
01-29-2014, 03:18 PM
Thank you, however, I don't think that would help create three different variables.

Yes you are right it is currently sent as 26-JAN-2014 but I need three different values sent seperately which I thought this calendar did as its three inputs.

Beverleyh
01-29-2014, 03:24 PM
You could explode the string into separate variables like this;


<?php

$string = '26-JAN-2014';

list($day, $month, $year) = explode('-', $string);

echo $day;
echo "<br/>";
echo $month;
echo "<br/>";
echo $year;

?>

jscheuer1
01-29-2014, 03:40 PM
Yes, or if you want all numbers:


$string = date('d m Y', strtotime('26-JAN-2014'));

list($day, $month, $year) = explode(' ', $string);

echo $day;
echo "<br/>";
echo $month;
echo "<br/>";
echo $year;

cruzier
01-29-2014, 04:05 PM
Hi, many thanks for this. How do I go about incorporating this code into the code provided by the date input calendar?

jscheuer1
01-29-2014, 04:20 PM
Are you using PHP?

cruzier
01-29-2014, 04:28 PM
Yes I am, many thanks.

jscheuer1
01-29-2014, 04:37 PM
Well you would just plug that in to your PHP back end to separate out the values for you that way. If you need help doing that we would need to see your page and the PHP back end but it would be something like:


$orderdate = isset($_GET['orderdate'])? $_GET['orderdate'] : false;
if(!$orderdate){die();}
$string = date('d m Y', strtotime($orderdate));

list($day, $month, $year) = explode(' ', $string);

After that, you would just use the separate $day, $month, $year values.