简体   繁体   中英

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. The Only Problem is that the script that uses the date subtracts 4 hours based on it's needs.

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.

Example:

I submit the form 10:00 am the Admin the reads it as 6 am

The Code in the admin of the script is compensating for 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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