Hello!
We are working on a project and one of its features is to store the login and logout times of a user when he/she access the website. It worked fine in localhost but when we transferred it on the the hosting site the login times were converted into UTC is there a way to convert it back to Philippine Standard Time?
Thank You!
What we did:
The Login time script:
“`
<?php
error_reporting(E_ALL);
ini_set(‘display_errors’, 1);
include(‘../server.php’);
$id = $_SESSION[‘user’][‘id’];
//var_dump($_SESSION);
$dataSend = $_POST[‘dataSend’];
date_default_timezone_set(‘Asia/Manila’);
//$date = date(“Y-m-d”);
$date=date(“n-j-Y”);
date_default_timezone_set(‘Asia/Manila’);
$time = date(“h:i:A”);
//create connection
$status = ‘1’;
//check connection
//start of the new script
$sql = “INSERT INTO attendancetracking (id, time_in, Room, status)
VALUES ($id, NOW(), ‘$dataSend’, $status)”;
//end of the new script
if ($db->query($sql) === TRUE) {
echo “new attendance was created”;
} else {
echo “2: ” . $sql . “<br>” . $db->error;
//echo”2″;
}
$db->close();
?>
We also tried another version using “`SET time_zone
this:
“`
<?php
include(‘../server.php’);
$id = $_SESSION[‘user’][‘id’];
//var_dump($_SESSION);
$dataSend = $_POST[‘dataSend’];
$sql = “SET time_zone = ‘+08:00′”; ***we also tried replacing +08:00 with Asia/Manila but still no luck***
$result = $db->query($sql);
//var_dump($db->error);
//create connection
$status = ‘1’;
//check connection
//start of the new script
$sql = “INSERT INTO attendancetracking (id, time_in, Room, status)
VALUES ($id, NOW(), ‘$dataSend’, $status)”;
//end of the new script
if ($db->query($sql) === TRUE) {
echo “new attendace was created”;
} else {
echo “2: ” . $sql . “<br>” . $db->error;
//echo”2″;
}
$result = $db->query($sql);
$db->close();
?>