Hello everyone,
Got a quick one (I hope), and probably an easy one.
For some reason it is eluding me at the moment.
Hoping someone can help.
I am building an ics file with PHP and the form that is submitting to
create this ics file has a jQuery date picker on it.
The date furnished comes to me like this "Saturday, January 1, 2012",
and a time furnished like "4:20 pm" with no seconds.
Now for the ics file, I need the date/time combo to be..
Ymd\THis\Z or in the case of the above date and time, 20120101T042000Z
Here is the block of code that I am using for this.
CODE [
...
}
else {
$dt_start = $_POST["field20"] ? $_POST["field20"] :
$_POST["field21"]; //Saturday, January 1, 2012
$dt_end = $_POST["field22"]; //Saturday, January 1, 2012
$t_start = $_POST["field24"]; //4:20 pm
$t_end = $_POST["field25"]; //5:55 pm
//date_default_timezone_set('UTC');
try {
$start_DT = new DateTime($dt_start . " " . $t_start);
$st_date_fmt = new DateTime($start_DT->format("l, F d, Y\TH:ia T"));
//$startdate_stamp = strtotime($st_date_fmt);
$startdate = $st_date_fmt->format('U');
//$startdate = date('Ymd\THis\Z', $startdate_stamp);
}
catch (Exception $e) {
trigger_error("startdate error: " . $e->getMessage(), E_USER_ERROR);
exit(1);
}
try {
if(empty($dt_end)) {
$enddate = $startdate + (60 * 60); //If no end date provided,
enddate is 1 hour after startdate.
} else {
$end_DT = new DateTime($dt_end . " " . $t_end);
$end_date_fmt = new DateTime($end_DT->format("l, F d, Y\TH:ia T"));
//$enddate_stamp = strtotime($end_date_fmt);
$enddate = $end_date_fmt->format('U');
//$enddate = date('Ymd\THis\Z', $enddate_stamp);
}
}
catch (Exception $e) {
trigger_error("enddate error: " . $e->getMessage(), E_USER_ERROR);
exit(1);
}
$stampnow = date('Ymd\THis\Z', time());
//$datestampnow = strtotime($stampnow);
}
...
]
I have a feeling I am mixing something up on my own, but I have been
staring at this code to long to see it.
Can anyone help me please? Like I said, this is probably an easy one.
TIA!!
Best,
Karl DeSaulniers
Design Drumm
http://designdrumm.com