<?php
session_start();

/**
 * Create SQL compliant TIMESTAMP and DATETIME values
 * from calendar field input.
 * 
 * Returns two variables, $timestamp and $datetime
 * which can be used in SQL+ operations.
 */

if(!isset($_SESSION['entry_key'])) { die(); }

// *********
//  EDIT THE TOKEN BELOW TO MATCH YOUR CALENDAR FIELD NAME
// *********

$input = F{date2}; // edit date2 to match

// Here we try to parse out a value set of dates (American)

$slash = explode('/', $input);
$dash = explode('-', $input);

if(count($slash) == 3){
$timestamp = mktime(0,0,0,$slash[0],$slash[1],$slash[2]);
$datetime = date('Y-m-d  H:i:s', $timestamp);
echo 'TIMESTAMP: ' . $timestamp . '<br/>';
echo 'DATETIME: ' . $datetime . '<br/>';
}

if(count($dash) == 3){
$timestamp = mktime(0,0,0,$dash[0],$dash[1],$dash[2]);
$datetime = date('Y-m-d  H:i:s', $timestamp);
echo 'TIMESTAMP: ' . $timestamp . '<br/>';
echo 'DATETIME: ' . $datetime . '<br/>';
}

// expand this logic to include spaces etc...

?>