Jump to content

Time and timezone issue


XCalibre1

Recommended Posts

I'm having an issue with getting my local time to work when filling out a reservation.  I am in Central time but it's 3 hours behind the server so when I make the reservation at 6am, my receipt transaction shows 4am.  So I decided to make the servertime central time  and that works.

<?php
 
date_default_timezone_set('America/Chicago');
$timezone = date_default_timezone_get();
echo "Server $timezone";
?>

This sets it now to a server time, at least on the reservation part, to CST, which is what I want, but when I still make a reservation it shows 3am instead of 6 am..... this is the conversion I am using:

$time = date("l jS \of F Y h:i:s A", strtotime("$date")) . "\n";

by the way, the above code gives the correct chosen date of their reservation, but time is off.  Well since that didn't work I tried this:

$time = date("l jS \of F Y h:i:s A", strtotime("$date", "$timezone")) . "\n";

It gives the correct reservation time now, but instead it's PM and not AM and it gives the date Wednesday December 31, 1969 6:00PM (rofl)

I hate dealing with time.  I just need the timezone of the user so it shows the correct time to them..... So if they are in California, it needs to say 6 am central ti me.... not california time...I don't want them making a 6am reservation and then get a receipt for 3am.... it's confusing....

Any ideas?  I've been on this for two days and haven't come up with a solution yet.   Geesh, if I can't even get my own time to show Central but 3 hours difference, how can I do anything else? lol I mean if the server is central and I'm central, you would thi nk the reservation time wou ld be central.  Thank you

 

Edited by XCalibre1
Link to comment
Share on other sites

23 minutes ago, XCalibre1 said:

So I decided to make the servertime central time

Like you started to hit on towards the end of your post, the actual problem you're trying to solve here is to display the time in the user's timezone. When you're the user, that means US Central. When I'm the user, that means US Pacific.

You have four options: you can guess their timezone, you can guess their timezone, you can ask for their timezone, or you can ignore their timezone.

"Ignore it?"

Potentially. What sort of reservations are you talking about here?

Link to comment
Share on other sites

5 minutes ago, requinix said:

Like you started to hit on towards the end of your post, the actual problem you're trying to solve here is to display the time in the user's timezone. When you're the user, that means US Central. When I'm the user, that means US Pacific.

You have four options: you can guess their timezone, you can guess their timezone, you can ask for their timezone, or you can ignore their timezone.

"Ignore it?"

Potentially. What sort of reservations are you talking about here?

Scuba diving reservations in Florida, and why can't I even make a reservation in MY timezone and it show like 3 hours difference?  It makes no logical sense.... if I make a 6 am reservation myself, it says 3 am lol...  mean I'm central, and server is now central.... smh

Edited by XCalibre1
Link to comment
Share on other sites

3 minutes ago, XCalibre1 said:

Scuba diving reservations in Florida,

Then it's easy: show the time of the reservation in Florida's timezone.
Look at most travel and reservations sites and you'll see them presenting the time in the local timezone. Why? Because if I'm going to go to Florida to go scuba diving, I have to be in Florida to do it. Plus, it's really easy to implement since you don't have to care about anybody's timezone but your own.

On the technical side, it's hard to tell for sure with what you've posted, but you're probably not using some of the date functions correctly. Certainly not if you're getting December 31st 1969 as output.

How is the user (you) choosing the date and time? What's the code for that part?

Link to comment
Share on other sites

5 minutes ago, requinix said:

Then it's easy: show the time of the reservation in Florida's timezone.
Look at most travel and reservations sites and you'll see them presenting the time in the local timezone. Why? Because if I'm going to go to Florida to go scuba diving, I have to be in Florida to do it. Plus, it's really easy to implement since you don't have to care about anybody's timezone but your own.

On the technical side, it's hard to tell for sure with what you've posted, but you're probably not using some of the date functions correctly. Certainly not if you're getting December 31st 1969 as output.

How is the user (you) choosing the date and time? What's the code for that part?

Here is my code.... I use the $_GET on the next page...  Code is a mess... but I clean it up later.

 

<?php
 
date_default_timezone_set('America/Chicago');
$timezone = date_default_timezone_get();
echo "Server $timezone";
?>


<script>
    
    var currentTime = new Date();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();

var suffix = "AM";

if (hours >= 12) {
    suffix = "PM";
    hours = hours - 12;
}

if (hours == 0) {
    hours = 12;
}

if (minutes < 10) {
    minutes = "0" + minutes;
}

document.write("<b>" + hours + ":" + minutes + " " + suffix + "</b>");

</script>


<?php
/*
 * Copyright 2012 Sean Proctor
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
   This file has the functions for the main displays of the calendar
*/

if ( !defined('IN_PHPC') ) {
       die("Hacking attempt");
}

// Full view for a single event
/**
 * @return Html|string
 */
function display_event()
{
	global $vars;

	if(!empty($vars['contentType']) && $vars['contentType'] == 'json')
		return display_event_json();

	if(isset($vars['oid']))
		return display_event_by_oid($vars['oid']);

	if(isset($vars['eid']))
		return display_event_by_eid($vars['eid']);

	// If we get here, we did something wrong
	soft_error(__("Invalid arguments."));
}

/**
 * @param int $oid
 * @return Html
 */
function display_event_by_oid($oid)
{
	global $phpcdb, $year, $month, $day;

	$event = $phpcdb->get_occurrence_by_oid($oid);

	$eid = $event->get_eid();

	if(!$event->can_read()) {
		return tag('p', __("You do not have permission to read this event."));
	}

	$event_header = tag('div', attributes('class="phpc-event-header"'),
			tag('div',attributes('class="phpc-event-creator"'), __('by').' ',
				tag('cite', $event->get_author())));

	$category = $event->get_category();
	if(!empty($category))
		$event_header->add(tag('div',attributes('class="phpc-event-cats"'), __('Category') . ': '
					. $category));

	$event_header->add(tag('div',attributes('class="phpc-event-time"'),
				__('When').": ".$event->get_datetime_string()));

	if(!empty($event->mtime))
		$event_header->add(tag('div', __('Last modified at: '),
				$event->get_mtime_string()));

	$menu_tag = tag('div', attrs('class="phpc-bar ui-widget-content"'));
	// Add modify/delete links if this user has access to this event.
        if($event->can_modify()) {
		$menu_tag->add(array(create_event_link(__('Modify'),
						'event_form', $eid), "\n",
					create_event_link(__('Delete'),
						'event_delete', $eid), "\n",
					create_occurrence_link(__('Modify Occurrence'),
						'occur_form', $oid), "\n",
					create_occurrence_link(__('Remove Occurrence'),
						'occurrence_delete', $oid),
					"\n"));
	}


	$occurrences = $phpcdb->get_occurrences_by_eid($eid);
		//$occurrence_div = tag('div', );
	$i = 0;
	while($i < sizeof($occurrences)) {
		if($occurrences[$i]->get_oid() == $oid)
			break;
		$i++;
	}
	// if we have a previous event
	$prev = $i - 1;
	if($prev >= 0) {
		$prev_occur = $occurrences[$prev];
		$menu_tag->add(create_occurrence_link(
					__('Previous occurrence on') . " " .
					$prev_occur->get_date_string(),
					'display_event',
					$prev_occur->get_oid()), ' ');
	}
	// if we have a future event
	$next = $i + 1;
	if($next < sizeof($occurrences)) {
		$next_occur = $occurrences[$next];
		$menu_tag->add(create_occurrence_link(
					__('Next occurrence on') . " " .
					$next_occur->get_date_string(),
					'display_event',
					$next_occur->get_oid()), ' ');
	}

	$menu_tag->add(create_event_link(__('View All Occurrences'),
				'display_event', $eid));

	$event_header->add($menu_tag);

	$year = $event->get_start_year();
	$month = $event->get_start_month();
	$day = $event->get_start_day();

	$desc_tag = tag('div',
			tag('h3', __("Description")),
			tag('p', attributes('class="phpc-desc"'),
				$event->get_desc()));

	return tag('div', attributes('class="phpc-main phpc-event"'),
			tag('h2', $event->get_subject()), $event_header,
			$desc_tag);
}

/**
 * @param int $eid
 * @return Html
 */
function display_event_by_eid($eid)
{
	global $phpcdb, $year, $month, $day;

	$event = new PhpcEvent($phpcdb->get_event_by_eid($eid));

	if(!$event->can_read()) {
		return tag('p', __("You do not have permission to read this event."));
	}

	$event_header = tag('div', attributes('class="phpc-event-header"'),
			tag('div', __('by').' ',
				tag('cite', $event->get_author())));

	if(!empty($event->mtime))
		$event_header->add(tag('div', __('Last modified at: '),
				$event->get_mtime_string()));

	$category = $event->get_category();
	if(!empty($category))
		$event_header->add(tag('div', __('Category') . ': '
					. $category));

	// Add modify/delete links if this user has access to this event.
        if($event->can_modify()) {
		$event_header->add(tag('div', attrs('class="phpc-bar ui-widget-content"'),
					create_event_link(__('Modify'),
						'event_form', $eid), "\n",
					create_event_link(__('Add Occurrence'),
						'occur_form', $eid), "\n",
					create_event_link(__('Delete'),
						'event_delete', $eid)));
	}

	$desc_tag = tag('div',
			tag('h3', __("Description")),
			tag('p', attributes('class="phpc-desc"'), $event->get_desc()));

	$occurrences_tag = tag('ul');
	$occurrences = $phpcdb->get_occurrences_by_eid($eid);
	$set_date = false;
	foreach($occurrences as $occurrence) {
		if(!$set_date) {
			$year = $occurrence->get_start_year();
			$month = $occurrence->get_start_month();
			$day = $occurrence->get_start_day();
		}
		$oid = $occurrence->get_oid();
		$occ_tag = tag('li', attrs('class="ui-widget-content"'),
				create_occurrence_link(
					$occurrence->get_date_string()
					. ' ' . __('at') . ' '
					. $occurrence->get_time_span_string(),
					'display_event',
					$oid));
		if($event->can_modify()) {
			$occ_tag->add(" ",
					create_occurrence_link(__('Edit'), 'occur_form', $oid), " ",
					create_occurrence_link(__('Remove'), 'occurrence_delete', $oid));
		}
		$occurrences_tag->add($occ_tag);
	}

	return tag('div', attributes('class="phpc-main phpc-event"'),
			tag('h2', $event->get_subject()), $event_header,
			$desc_tag, tag ('div',attributes('class="phpc-occ"'),tag('h3', __('Occurrences')),
			$occurrences_tag));
}

// generates a JSON data structure for a particular event
/**
 * @return string
 */
function display_event_json()
{
	global $phpcdb, $vars;

	if(!isset($vars['oid']))
		return "";

	$event = $phpcdb->get_occurrence_by_oid($vars['oid']);

	if(!$event->can_read())
		return "";


	$time_str = $event->get_time_span_string();
	$date_str = $event->get_date_string();

	if(empty($category))
		$category_text = '';
	else
		$category_text = __('Category') . ': ' . $event->get_category();

		if ($time_str!="") $time="$date_str " . __("from") . " $time_str";
		else $time="$date_str ";

	return json_encode(array("title" => $event->get_subject(),
				"time" => $time,
				"body" => $event->get_desc()));
}














function get_event_by_oid($oid)
{
  $events_table = SQL_PREFIX . 'events';
  $occurrences_table = SQL_PREFIX . 'occurrences';
  $users_table = SQL_PREFIX . 'users';
  $cats_table = SQL_PREFIX . 'categories';
  $reservations_table = SQL_PREFIX . 'date';

  $query = "SELECT " . $this->get_event_fields()
    .", `username`, `name`, `bg_color`, `text_color`\n"
    ."FROM `$events_table`\n"
    ."LEFT JOIN `$occurrences_table` USING (`eid`)\n"
    ."LEFT JOIN `$users_table` ON `uid` = `owner`\n"
    ."LEFT JOIN `$cats_table` USING (`catid`)\n"
    ."LEFT JOIN `$reservations` USING (`date`)\n"
    ."WHERE `oid` = '$oid'\n";

  $sth = $this->dbh->query($query)
    or $this->db_error(__('Error in get_event_by_oid'),
        $query);

  $result = $sth->fetch_assoc()
    or soft_error(__("Event doesn't exist with oid")
        . ": $oid");

  return $result;
}

echo"   <br><br><div class='openBtn'>";
echo"     <button class='openButton' onclick='openForm()'><strong>Make Reservation</strong></button>";
echo"   </div>";
echo"   <div class='loginPopup'>";
echo"     <div class='formPopup' id='popupForm'>";
echo"       <form action='/calendar/src/action_page.php' class='formContainer'>";
echo"         <h2>Reservation Form</h2>";

















echo"         <label for='fname'>";
echo"           <strong>First Name</strong>";
echo"         </label>";
echo"         <input type='text' class='fname' id='fname' placeholder='First Name' name='fname' required>";
echo"         <input type='text' id='oid' value='$_GET[oid]' name='oid' hidden >";
echo"         <label for='lname'>";
echo"           <strong>Last Name</strong>";
echo"         </label>";
echo"         <input type='text' class='lname' id='lname' placeholder='Last Name' name='lname' required>";
echo"         <strong><label for='phone'>Phone Number:</label></strong><br>";
echo"         <input type='tel' class='mytext' id='phone' name='phone' placeholder='   123-459-6780' pattern='[0-9]{3}-[0-9]{3}-[0-9]{4}' required><br>";
echo"         <small>Format: 123-459-6780</small><br><br>";
echo"         <label for='email'>";
echo"           <strong>Email<br></strong>";
echo"         </label>";
echo"         <input type='email' id='email'class='email' placeholder='test@example.com' name='email' required><br><br>";
echo"     <label for='dropdown'>";
echo"     <strong>How many in your party?</strong>&nbsp;";
echo"     </label>";
echo"     <select name = 'dropdown' id = 'wgtmsr' name = 'dropdown' required>";
echo"     <option value = '1' selected>1</option>";
echo"     <option value = '2'>2</option>";
echo"     <option value = '3'>3</option>";
echo"     <option value = '4'>4</option>";
echo"     <option value = '5'>5</option>";
echo"     <option value = '6'>6</option>";
echo"     <option value = '7'>7</option>";
echo"     <option value = '8'>8</option>";
echo"     </select><br><br>";
echo"     <label for='dove'>";
echo"     <strong>Have you ever dived before?</strong>&nbsp;";
echo"     </label>";
echo"     <select name = 'dove' id = 'dove' name = 'dove' required>";
echo"     <option value = 'No' selected>No</option>";
echo"     <option value = 'Yes'>Yes</option>";
echo"     </select><br><br>";
echo" <textarea name='summary'";
echo"             rows='10' cols='32' readonly noborder>";
echo" We take pride in using profressional cleaning supplies on our masks and snorkels, to ensure they are germ free from being used, and is included in the price of your dive.  If you are uncomfortable using them, and you do wish to purchase one, it will be an additional $45.00 to get your own.";
echo"   </textarea><br /><br />";
echo"         <button type='submit' class='btn' onclick>Make Your Reservation Now</button>";
echo"         <button type='button' class='btn cancel' onclick='closeForm()'>Close</button>";
echo"       </form>";
echo"     </div>";
echo"   </div>";
?>
  <script>
    function openForm() {
      document.getElementById('popupForm').style.display = 'block';
    }
    </script>

<script>
    function closeForm() {
      document.getElementById('popupForm').style.display = 'none';
    }
  </script>
  <style>
      * {
        box-sizing: border-box;
      }

.dropbtn {
  background-color: #04AA6D;
  color: white;
  padding: 16px;
  font-size: 16px;
  border: none;
}

.dropdown {
  position: relative;
  display: inline-block;
}
#fname{
height: 40px;
width: 260px;
background-color: #F5F5F5;
}
#lname{
height: 40px;
width: 260px;
background-color: #F5F5F5;
}
#wgtmsr{
height: 25px;
}
#dove{
height: 25px;
}
#email{
height: 40px;
width: 260px;
background-color: #F5F5F5;
}
.mytext {
    width: 260px;
    height: 40px;
    background-color: #F5F5F5;
}
textarea {
    border: none;
    outline: none;
    text-align: justify;
    white-space: normal;
}
.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f1f1f1;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 1;
}

.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}
.dropdown-content a:hover {background-color: #ddd;}

.dropdown:hover .dropdown-content {display: block;}

.dropdown:hover .dropbtn {background-color: #3e8e41;}
      .openBtn {
        display: flex;
        justify-content: left;
      }
      .openButton {
        border: none;
        border-radius: 5px;
        background-color: #1c87c9;
        color: white;
        padding: 14px 20px;
        cursor: pointer;
        position: fixed;
      }
      .loginPopup {
        position: relative;
        text-align: center;
        width: 100%;
      }
      .formPopup {
        display: none;
        position: fixed;
        left: 45%;
        top: 5%;
        transform: translate(-50%, 5%);
        border: 3px solid #999999;
        height: 800px;
        z-index: 9;
      }
      .formContainer {
        max-width: 300px;
        max-height: 500px;
        padding: 5px;
        background-color: #fff;
      }
      .formContainer .btn {
        padding: 12px 20px;
        border: none;
        background-color: #8ebf42;
        color: #fff;
        cursor: pointer;
        width: 100%;
        margin-bottom: 15px;
        opacity: 0.8;
      }
      .formContainer .cancel {
        background-color: #cc0000;
      }
      .formContainer .btn:hover,
      .openButton:hover {
        opacity: 1;
      }
    </style>

 

Link to comment
Share on other sites

Then the time I use on the page I use the GET I already sh owed you:

$time = date("l jS \of F Y h:i:s A", strtotime("$date")) . "\n";

echo" <fieldset disabled>";
echo" <legend>Your Reservation Date</legend>";
echo" <input type='text' class='textarea' name='date' id='textarea' readonly placeholder='$time'></textarea>";
echo" </fieldset>";

 

Edited by XCalibre1
Link to comment
Share on other sites

If you need the whole code to the action_page.php hre it is without the databasae connections


<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>


<?php
 
date_default_timezone_set('America/Chicago');
$timezone = date_default_timezone_get();
echo "Server $timezone";
?>

<br><br>
 

<?php
$fname = $_GET['fname'];
$lname = $_GET['lname'];
$phone = $_GET['phone'];
$dropdown = $_GET['dropdown'];
$oid = $_GET['oid'];
$dived = $_GET['dove'];
$email = $_GET['email'];
$date = $_GET['date'];

echo" <div width='500px'>";
echo" <form method='post' id='formABCs'>";
echo" <fieldset disabled>";
echo" <legend>Your Name</legend>";
echo" <input type='text' class='textarea' name='name' id='textarea' readonly placeholder='$fname $lname'><br>";
echo" </fieldset>";

echo" <fieldset disabled>";
echo" <legend>Your Email</legend>";
echo" <input type='text' class='textarea' name='email' id='textarea' readonly placeholder='$email'></textarea>";
echo" </fieldset>";

echo" <fieldset disabled>";
echo" <legend>Your Phone Number</legend>";
echo" <input type='text' class='textarea' name='phone' id='textarea' readonly placeholder='$phone'></textarea>";
echo" </fieldset>";

echo" <fieldset disabled>";
echo" <legend>Have you ever dived before</legend>";
echo" <input type='text' class='textarea' name='dived' id='textarea' readonly placeholder='$dived'></textarea>";
echo" </fieldset>";

echo" <fieldset disabled>";
echo" <legend>How many in your party</legend>";
echo" <input type='text' class='textarea' name='dropdown' id='textarea' readonly placeholder='$dropdown'></textarea>";
echo" </fieldset>";
?>


 













$time = date("l jS \of F Y h:i:s A", strtotime("$date")) . "\n";

echo" <fieldset disabled>";
echo" <legend>Your Reservation Date</legend>";
echo" <input type='text' class='textarea' name='date' id='textarea' readonly placeholder='$time'></textarea>";
echo" </fieldset>";

$alph = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$code='';

for($i=0;$i<15;$i++){
   $code .= $alph[rand(0, 35)];
}

echo" <button name='submit' id='btn' value='Submit' onclick\"hideButton()\">Click to Verify Information</button>";
echo" </form>";
?>


<script>

function hideButton(){

document.getElementById('btn').style.display= 'none';
$("#btnSubmit").attr("disabled", true);
}


</script>


<script>
$(document).ready(function() {
///// show ///
$('#b1').click(function(){

	if($('#b1').attr('value')=='Hide'){
	$(this).val('Show'); // change the value to Show
	$('#formABCs').hide();

	}else{

	$(this).val('Your Reservation Has Successfully Been Created.  See you at the beach!'); // change the value to Hide
	$('#formABCs').hide();
	}

})
})
</script>







<?php
if (isset($_POST["submit"])) {
   
     $fname = $_GET['fname'];
     $lname = $_GET['lname'];
     $phone = $_GET['phone'];
     $dropdown = $_GET['dropdown'];
     $oid = $_GET['oid'];
     $dived = $_GET['dove'];
     $email = $_GET['email'];

    if(! get_magic_quotes_gpc() ) {
      $fname = addslashes ($fname);
      $lname = addslashes ($lname);
      $email = addslashes ($email);
      $phone = addslashes ($phone);
      $dived = addslashes ($dived);
      $dropdown = addslashes ($dropdown);
      $date = addslashes ($date);
      $newdate = addslashes ($newdate);
      $resnum = addslashes ($code);

      } else {
      $fname = $_GET['name'];
      $email = $_GET['email'];
      $lname = $_GET['lname'];
      $phone = $_GET['phone'];
      $dived = $_GET['dived'];
      $dropdown = $_GET['dropdown'];
    }
      $sql = "INSERT INTO reservations ".
          "(fname,email,lname,phone,dived,dropdown,reserved,resnum) "."VALUES ".
          "('$fname','$email','$lname','$phone','$dived','$dropdown','$newdate','$resnum')";

              if ($conn->query($sql)) {

                echo" <input type='button' id='b1' value='Your Reservation Is Processing...Click Here to Finilize!'><br><br>";


                  echo" <textarea class='reserved' name='reserved' id='reserved'>$code</textarea>";

                  echo" <textarea class='save' id='blink'>  Please copy, paste, and save your Reservation Number!</textarea>";
                  echo" </form>";
              }
              if ($conn->connect_error) {
                  printf("Could not insert record into table: %s<br />", $mysqlierror);
              }
$conn->close();
}
?>

<style>
legend {
    background-color: #fff;
    color: #000;
    padding: 3px 6px;
}
*:read-only {
    font-weight: bold;
    color: red;
    font-size: 12px;
}
div {
  width: 37%;
  margin: auto;
}
input {
    border: none;
    outline: none;
    font-size:1.3em;
    padding:.5em;
    white-space: normal;
    font-weight: bold;
    resize: none;
    width: 500px
}
input:read-only {
    background-color: yellow;
}
textarea {
  resize: none;
  height: 30px;
}
.reserved {
font-size: 20px;
width: 500px;
text-align: center;
}
.save {
font-size: 18px;
width: 525px;
height: 45px;
text-align: center;
border: none;
outline: none;
overflow: hidden;

}
#submit {
	border:1px solid #000;
	color:#000;
	padding:0;
	overflow:hidden;
	height:40px;
	font-weight:bold;
	text-align:center;
  margin-left: 10px;
}
#submit:hover {
	background:#000;
	color:#fff
}
#blink {
  font-size: 20px;
  font-weight: bold;
  font-family: sans-serif;
  color: #1c87c9;
  transition: 0.4s;
}
</style>

<script type="text/javascript">
      var blink = document.getElementById('blink');
      setInterval(function() {
        blink.style.opacity = (blink.style.opacity == 0 ? 1 : 0);
      }, 1000);
</script>

 

But it sthows 2 hours behind...... I have it set for 5 am but the reservation says 3am..... and I'm central time and the server is sset to central time, so it makes no sense to me.  It does give the correct date chosen for the day of reservervation; it's the time messed up.

Edited by XCalibre1
add more
Link to comment
Share on other sites

also to make it clearer..... the time in occurance is 

2023-04-11 15:00:00 with date as the field, which is right.... 5am....

and then I used the formula   $date = $row["start_ts"]; which shows the above time..... then I use the next formula

$time = date("l jS \of F Y h:i:s A", strtotime("$date")) . "\n";
 

it shows the right date, but the ti me is 2 hours still behind, showing 3am using the server time, even though I have set the serve timezone to Central.

 

Edited by XCalibre1
Link to comment
Share on other sites

That only works for you in your timezone, because you're adding the offset specific to your timezone. You have a choice here - either ask the user what timezone they're in and offset to that, or display in one timezone and let your users know you're doing that. Either way, convert all dates and times to GMT before saving it in the database and convert it on output.

Either way, the code you've posted is clearly not the code you're using - that last block closes PHP and then continues to use PHP. You're also checking to see if magic quotes are enabled - I believe those were removed in version 5 or so? They're gone, ignore them and the add_slashes() function. Use PDO with prepared statements.

Your Javascript is manually doing a whole lot of what the Date object does natively, and I'm not honestly sure why you're even bothering with the Javascript in this case.

Finally, your form markup tags don't match - you open a text input and then close a textarea. In addition, you're using the field as an output - there's no need for it to be a form field, just output the value.

Basically, you're beyond the point where you can acknowledge that the code is a mess that needs to be cleaned up; you need to clean up the code before you can proceed.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.