简体   繁体   English

增加4小时的UTC时间

[英]add 4 hours for UTC Time

So i create a form outside of this calendar script I am using. 因此,我在使用的日历脚本之外创建了一个表单。

I am submitting a date from a Java Date Picker works great. 我正在从Java Date Picker提交日期,效果很好。 The Only Problem is that the script that uses the date subtracts 4 hours based on it's needs. 唯一的问题是,使用日期的脚本会根据需要减去4个小时。

Is there a way to add 4 hours to the submitted date so it shows up correctly in the admin when they go to approve the event that was submitted. 有没有一种方法可以在提交日期前增加4个小时,以便当他们批准提交事件时可以在管理员中正确显示。

Example: 例:

I submit the form 10:00 am the Admin the reads it as 6 am 我提交表格10:00 am Admin读取为6 am

The Code in the admin of the script is compensating for UTC. 脚本管理中的代码补偿UTC。

<?php
   if (!isset($_POST['submit'])) {
   ?>
   <?php
    } else {
   $input_arr = array();
   foreach ($_POST as $key => $input_arr) {

      $_POST[$key] = addslashes($input_arr);

   }
  $user_id = $_POST['user_id'];
  $listing_id = $_POST['listing_id'];
   $status = $_POST['status'];
   $title = $_POST['title'];
   $description_short = $_POST['description_short'];
   $description = $_POST['description'];
   $venue = $_POST['venue'];
   $location = $_POST['location'];
   $admission = $_POST['admission'];
   $contact_name = $_POST['contact_name'];
   $website = $_POST['website'];
   $email = $_POST['email'];
   $phone = $_POST['phone'];
   $date = $_POST['date'];
   $date_start = $_POST['date_start'];
   $date_end = $_POST['date_end'];



   mysql_query("INSERT INTO `pmd_events` (user_id, listing_id, status, title, description_short, description, venue, location, admission, contact_name, website, email, phone, date, date_start, date_end) VALUES ('$user_id', '$listing_id', '$status', '$title', '$description_short', '$description', '$venue', '$location', '$admission', '$contact_name', '$website', '$email', '$phone', '$date', '$date_start', '$date_end')");

   $id = mysql_insert_id();

   mysql_query("INSERT INTO `pmd_events_dates`     (event_id,date_start,date_end,rsvp_reminder_sent) VALUES ($id,'$date_start', '$date_end',0)");
   echo "verbage";
   }

   ?>

Its very likely what's being submitted contains a time zone. 提交的内容很可能包含一个时区。 The difference is what is submitted vs the submitters timezone. 区别在于提交的内容与提交者的时区。

Either don't send the time zone or trim the value to ignore the time zone. 不要发送时区或修剪值以忽略时区。 You could even do both 你甚至都可以做

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM