1. global $user;
  2. $user_timezone_name = date_default_timezone_name(TRUE);
  3. $user_timezone = date_default_timezone(TRUE);
  4.  
  5. // Convert the user entered date into a PHP 5 DateTime object
  6. $local_date = new DateTime($text_date);
  7.  
  8. // Reformat the user entered date into an ISO date that date_make_date() will accept
  9. $iso_date_string = date_format_date($local_date, 'custom', 'Y-m-d\TH:i:s');
  10.  
  11. // Create a DateTime object with the user's timezone info
  12. $utc_date = date_make_date($iso_date_string, $user_timezone_name, DATE_DATETIME);
  13.  
  14. // Change the timezone to UTC
  15. date_timezone_set($utc_date, timezone_open('UTC'));
  16.  
  17. // Format the UTC version of the DateTime for use in node->save()
  18. $utc_date_string = date_format_date($utc_date, 'custom', 'Y-m-d\TH:i:s');
  19.  
  20. return $utc_date_string;