PHP - Date.timezone Setting Error
Ok well i have a virtual world, my friendcoded the emulator. In PHP but he's on holiday for 2 weeks. I keep getting
Quote PHP Warning: PHP Startup: It is not safe to rely on the system's timezone setti ngs. You are *required* to use the date.timezone setting or the date_default_tim ezone_set() function. In case you used any of those methods and you are still ge tting this warning, you most likely misspelled the timezone identifier. We selec ted 'Europe/London' for '0.0/no DST' instead in Unknown on line 0 PHP Warning: eval(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone _set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ' Europe/London' for '0.0/no DST' instead in C:\inetpub\wwwroot\main\server\chapat iz.php(2) : eval()'d code on line 4 But there are only 4 lines in chapatiz.php and it has nothing to do with it i think Quote <?php eval(file_get_contents('serv_original.ini')); ?> Here's chapatiz.php (Its attached since its big) Quote //config $socketurl = "munizonline.co.uk; $httpurl = "munizonine.co.uk; $rootPath = "c:/inetpub/wwwroot/"; // SQL SETTINGS $host = 'localhost'; $user = 'root'; $dbname = 'chapatiz'; $password = '---'; $sqli = new mysqli("p:". $host, $user, $password, $dbname); // create a persistant sql connexion (keepAlive) $banned_ips = array(); ///// ADD BAN BY IP FROM HTACCESS $filename = $rootPath.".htaccess"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle); $contents = utf8_decode($contents); $ex = explode("\n", $contents); $exf = array(); foreach ($ex AS $k => $str) { if(preg_match('`deny from (.*?) \#`', $str, $sortie)) { $return = $sortie[1]; array_push($exf, $return); } } foreach ($exf AS $k => $str) { array_push($banned_ips, $str); } // LOG ALL ACTIONS function dolog($text) { $myFile = "c:/inetpub/wwwroot/main/log/chat.txt"; $fh = fopen($myFile, 'a'); fwrite($fh, $text. "\n"); fclose($fh); } function serve($r) { return file_get_contents('C:/inetpub/wwwroot/main/server/serve/'. $r. '.php'); } function getitems($name) { return file_get_contents('http://munizonline.co.uk/main/items.php?u='. $name); } function haveitem($name, $item) { $c = file_get_contents('http://munizonline.co.uk/main/items.php?u='. $name); $pattern = '/"'. $item .'"/'; $pattern2 = '/"0'. $item .'"/'; if ((preg_match($pattern, $c)) OR (preg_match($pattern2, $c))) { return true; } else { return false; } } function dotag($tag) { $tag = explode('##', $tag); $tags = array(); foreach ($tag AS $k => $v) { list($name, $value) = explode('=', $v); $tags[$name] = $value; } return $tags; } function updatetag($tags, $tochange, $value) { $tags[$tochange] = $value; $new = "##"; foreach ($tags AS $k => $v) { $new .= $k. "=". $v. '##'; } return $new; } ini_set('display_errors', '1'); error_reporting(0); $quete8 = $sqli->query('UPDATE phpbb_users SET online = 0'); function cmd() { return false; } $modee = false; session_start(); $_SESSION['start'] = "yess"; $mainsock = socket_create(AF_INET, SOCK_STREAM, 0); //modifiez la prochaine ligne si besoin $pport = rand(81, 8000); while (!socket_bind($mainsock, $socketurl, $pport)) { $pport = rand(81, 8000); echo "\n port modified to ". $pport. "\n"; } $myFile = $rootPath."main/server/socket.php"; $fh = fopen($myFile, 'w+') or die("can't open file"); fwrite($fh, $socketurl. ":". $pport); fclose($fh); socket_set_nonblock($mainsock); socket_listen($mainsock); $clients=Array(); $compteur=0; $write = NULL; $except = NULL; $lol = NULL; $race = "0"; $flag = "0"; date_default_timezone_set('Europe/London'); $ok_marry = "0"; $ok_pv = "0"; function random($car) { $string = ""; return $string; } function random3($car3) { $string3 = ""; return $string3; } function random2($car2) { $string2 = ""; return $string2; } function random1($car1) { $string1 = ""; return $string1; } echo("Waiting for players!\n"); $file = file_get_contents($rootPath.'main/server/server_while.php'); $lasteval = time(); while(true){ if ($lasteval <= strtotime('-1 minute')) { if (file_exists($rootPath."main/server/server_while.php")) { $file = file_get_contents($rootPath.'main/server/server_while.php'); } $lasteval = time(); echo "\neval again\n\n"; } eval($file); } I have no clue whats wrong it use to work. Similar TutorialsHi Guys.. How can I change a date on the fly ? Everything is UTC on my server. How can I change a date to something else on the fly? Ie: $timezone = "cet"; $datetime = "2011-09-04 19:53:00"; echo $datetime($timezone); So I can give it a datetime and have it echo the datetime as if it were in the other timezone? Thanks Graham Nonsense question, but still... Is there any method to detect gmail client timezone setting? Like mobile app and web gmail client? Not browser or IP or similar, but gmail. Thank you for your answers. I'm working on a project that has a lot of different timezone options, and all I have from the users is their UTC offset. After weeks of doing tweaks, I come to new issues every time I add something, one would think it would be a lot easier to just get the correct time and day :) The latest issue is that when I try to rewrite a date to a better fomat, it disregards the GMT offset. Like this: 4/14/19, 12:00 PM GMT+2 (=$date) becomes ... 14-04-2019 10:00 when using this code: $bp_date_to_format = date_create_from_format('Y-m-d\TH:i:sP', $date); echo date_format($bp_date_to_format, 'd-m-Y H:i'); I figured it would just rewrite the format, keeping the exact time. It isn't. We do have all these sorts of localization functions as well, but because there doesn't seem to be one single standard (each 3rd party API connection we have uses its own default datetime format so it seems). // Remove UTC Text $UTC_offset = str_replace('UTC', '', $timezone); // Get Offset in Minutes if (stripos($UTC_offset, ':') !== false) { // Calculate seconds from offset list($hours, $minutes) = explode(':', $offset); $seconds = $hours * 60 * 60 + $minutes * 60; } else { $seconds = $UTC_offset * 60 * 60; } // Get User timezone name from seconds $timezone = timezone_name_from_abbr('', $seconds, 1); if ($timezone === false) { $timezone = timezone_name_from_abbr('', $seconds, 0); } // Set new TZ return date_default_timezone_set($timezone);
Isn't there any "one way"solution that can be used? It's confusing to say the least.
Cheers. I have a Xampp Timezone Error Error Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for '-5.0/no DST' instead in C:\Users\cory j\Desktop\xampp\htdocs\NoXIp\Toplist\inc\vote.php on line 56 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' NOW())' at line 1 Line 56 $diffrence = time() - strtotime($getDate['lastVoteDate']); The Date Function in Php.ini [Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone = "America/New_York" date.timezone = "America/New_York" ; http://php.net/date.default-latitude ;date.default_latitude = 31.7667 ; http://php.net/date.default-longitude ;date.default_longitude = 35.2333 ; http://php.net/date.sunrise-zenith ;date.sunrise_zenith = 90.583333 ; http://php.net/date.sunset-zenith ;date.sunset_zenith = 90.583333 Hi,
Please help to resolve this script.
Default time zone is not working properly it shows time only in AM (PM is not working) and in the INDIAN time 7:00pm to 7:00am table never fetch any content.
<div class="cart"> <table width="100%" height="100%" cellspacing="0" cellpadding="10"> <tbody> <tr style="margin: 5px; padding-bottom: 5px; background-color:#ececec; line-height:30px"> <td style="width: 10%;"> <span> Sr. No. </span> </td> <td style="width: 15%;"> <span> Order Id </span> </td> <td style="width: 35%;"> <span> Order Date / Time </span> </td> <td style="width: 10%;"> <span> Amount </span> </td> <td style="width: 35%;"> <span> Coupon Name </span> </td> <td style="width: 10%;"> <span> Action </span> </td> </tr> <tr> <td colspan="5" height="10"></td> </tr> <?php date_default_timezone_set("Asia/Dili"); $session_user_id = $_SESSION['userId']; $ordercount=1; $current_date = date('Y-m-d'); $order_id = $_SESSION['new_order_id']; $query = "select * from cs_order where order_id = '$order_id'"; if(!($result = mysql_query($query))) { echo $query.mysql_error(); exit; } $order_items = mysql_fetch_array($result); $order_transaction_id = $order_items['order_transaction_id']; $order_transaction_date = $order_items['order_transaction_date']; $order_currency_id = explode(", ", $order_items['order_currency_id']); $order_amount = $order_items['order_amount']; $order_coupon_id = explode(", ", $order_items['order_coupon_id']); $new_order_currency_id = $order_currency_id[0]; if(strtotime(date('Y-m-d', strtotime($order_transaction_date)))==strtotime($current_date)) { ?> <tr> <td style="width: 10%;"> <span> <?=$ordercount; ?> </span> </td> <td style="width: 10%;"> <span> <?=$order_transaction_id; ?> </span> </td> <td style="width: 25%;"> <span> <?=date('d M Y / h:i a', strtotime($order_transaction_date)); ?> </span> </td> <td style="width: 10%;"> <span> <?=$new_order_currency_id; ?> <?=$order_amount; ?> </span> </td> <td style="width: 25%;"> <span> <?php $user_id = $_SESSION['userId']; $current_date = date('Y-m-d'); $order_id = $_SESSION['new_order_id']; $query = "select * from cs_order as ord left join cs_countries as country on ord.order_country = country.country_id left join cs_states as state on ord.order_state = state. state_id left join cs_cities as city on ord.order_city = city. city_id where ord.order_id = '$order_id' and ord.order_user_id = '$user_id' and ord.order_transaction_date like '$current_date %:%:%'"; if(!($result = mysql_query($query))) { echo $query.mysql_error(); exit; } $total_invoice_amount = 0; while($invoice = mysql_fetch_assoc($result)) { $invoice_record[] = $invoice; } ?> <?php echo $invoice_record[0]['order_coupon_name']; ?> </span> </td> <td style="width: 15%;" align="center"> <span> <form action="" method="post" name="formGetcode"> <?php foreach($order_coupon_id as $coup_id) { $checkout_couponid = $coup_id['order_coupon_id']; $checkoutquery = "select * from cs_coupons as coup left join cs_company as comp on coup.coupons_store = comp.retailer_id where coup.coupons_id = '$checkout_couponid'"; if(!($checkoutresult = mysql_query($checkoutquery))) { echo $checkoutquery.mysql_error(); exit; } $coupon = mysql_fetch_array($checkoutresult); $checkout_couponurl = $coupon['coupons_website']; $coup_type = $coupon['coupons_type']; ?> <?php if($coup_type=='R') { ?> <button class="submit button" type="button" onclick="getCodePopup(<?=$checkout_couponid; ?>, '<?=$checkout_couponurl; ?>');" style="font-size:11px;width:86px;">Get Code</button> <?php } else { ?> <button class="submit button" type="button" onclick="getPrintPopup(<?=$checkout_couponid; ?>);" style="font-size:11px;width:86px;">Print Coupon</button> <?php } } ?> </form> </span> </td> </tr> <?php $ordercount++; } ?> <tr> <td colspan="5" height="20"></td> </tr> </tbody> </table> </div> </div><!--cart container close here--> And <script type="text/javascript"> function getCodePopup(str1, str2) { var cid = str1; var curl = str2; window.open('getcouponcode.php?id=' +cid, 'open_window', ' width=540, height=480, left=0, top=0'); window.open(curl,'_blank'); } function getPrintPopup(str1) { var cid = str1; window.open('printCoupon.php?id=' +cid, 'open_window1', ' width=640, height=320, left=0, top=0'); } </script>Pop Up code not fetching Coupon ID after number 9. Please help me to solve this. Thanks. Paresh Edited by mac_gyver, 13 June 2014 - 03:09 AM. code tags please i have this code to set a date to the 1st of the previous month -- SELECT DATE_FORMAT(DATE_SUB(tbl_col, INTERVAL 1 MONTH), '%Y-%m-01') FROM table can it be changed to set date to first Monday in that month...? Hi I'm having a problem getting a query to work. I have a simple form with user input for start and end date with format: 2009-03-19 (todays date): $Startdate = $_POST['date']; This works well when something is entered into the form, and afterwards using my query: SELECT COUNT(*) as total FROM mydb WHERE Date BETWEEN '$Startdate' AND '$EndDate' ........ Problem is if user submits the form without entering anything in the date input fields, which makes sense. I want to check if inputs has been made, and if not set af default date, but can't make it work: if (isset($_POST['date']) && $_POST['date'] !='') { $Startdate = $_POST['date'];} else { $Startdate = '1980-01-01';} How can I set $Startdate to something that can be used in the query as below doesn't work? I am getting syntax error, unexpected T_CONSTANT_ENCAPSED_STRING on the date stamp line below but I can't see what is causing the problem. when I comment it out the problem goes away so I know I it is there. please help. $email_message = "Form details below.\n\n"; $email_message = date("m/d/Y")"\n"; Hello, I've been working on a search script that call on a function to retrieve info from my database. What I'm trying to do next is to echo various errors e.g. No search results to display. At the moment I have three messages I would like to display based on the user input but it is not working when I try to set up a second functions within the same tags. I have got it working by using header:location but it would be much faster and easier to just echo the messages on one page I will post the code below. Code: [Select] <?php require_once('Connections/price_db.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); //this is the function I would like to add function showErrors($error1 = "", $error2 = "", $error3 = ""){ $var = $_GET['search'] ; $error = false; $error1 = ""; $error2 = ""; $error3 = ""; if (strlen ($var) < 3){ $error = true; $error1 = "You Must Enter At Least Three Characters To Search"; } if (strlen ($var) == 0) { $error = true; $error2 = "Please Enter a Search"; } if ($totalRows_Recordset1 == 0){ $error = true; $error3 = "Your Search Returned No Results"; } if ($error){ showErrors($error1,$error2,error3); } //above is where I have come into troubles switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } }} $colname_Recordset1 = "-1"; if (isset($_GET ['search'])) { $colname_Recordset1 = $_GET['search']; } mysql_select_db($database_price_db, $price_db); $query_Recordset1 = sprintf("SELECT * FROM price_db WHERE tb_name LIKE %s OR tb_desc LIKE %s", GetSQLValueString("%" . $colname_Recordset1 . "%", "text"),GetSQLValueString("%" . $colname_Recordset1 . "%", "text")); $Recordset1 = mysql_query($query_Recordset1, $price_db) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> and this is the html for it Code: [Select] <div class="bold_14"> <?php echo $error1 ?> <?php echo $error2 ?> <?php echo $error3 ?> </div> Hi guys I am working on adding a third party php members register and login into a clients web site but every time I try the regidter page is shows me this error message. Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'username'@'localhost' (using password: YES) in /home/cpassoc2/public_html/register-exec.php on line 15 Failed to connect to server: Access denied for user 'username'@'localhost' (using password: YES) This is what i have in the config.php page. <?php define('DB_HOST', 'localhost'); define('DB_USER', 'cpassoc2-memark'); define('DB_PASSWORD', '?????????'); password replaced define('DB_DATABASE', 'cpassoc2-me'); ?> I have set up the my SQL within the control panel of the site, So do i need to do any thing else???, what am i missing???. Mark..... I am getting this error when I output a formatted date... Quote Warning: date() expects parameter 2 to be long, string given in I am using DATETIME. What do I need to do to fix things? Here is my code... Code: [Select] echo '<p class="commentDate">' . date($createdOn, 'g:ia') . ' on ' . date($createdOn, 'M j, Y') . '</p>'; Debbie Hello, The below code works on my home machine.. but not on my Linux machine, I am unable to figure out the problem, please help Code: [Select] require_once("dbconnection.php"); function coun_list() { $rs=mysql_query("select name from timezones") or die(mysql_error()); while($row=mysql_fetch_row($rs)) { $tzone=$row[0]; if($tzone=='Asia/Calcutta') $tzone='Asia/Kolkata'; try { $tz = new DateTimeZone("$tzone"); $lt=$tz->getLocation(); $lat=$lt['latitude']; $lon=$lt['longitude']; echo "$tzone"; } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } } } coun_list(); I get the below error on my Linux machine, Code: [Select] Caught exception: DateTimeZone::__construct() [datetimezone.--construct]: Unknown or bad timezone () Please help me to figure out the issue.. My script reports the time with a six minute error added to the current time. I can't figure out why. I wrote a different script for solar calculation and get a 7 minute error subtracted. I'm hoping a response to this post will help me solve both problems. I abbreviated the six minute error script to simplify the problem. =====================================================
date_default_timezone_set("America/New_York"); ======================================================= Here is the code im using $dateOfBirth = ''; preg_match('|Born on ([a-zA-Z]*\s[0-9]*,\s[0-9]*)\\\u003c\\\/span>|', $page, $match); if($match && count($match)>0) { $date = str_replace(",","",$match[1]); blue($date); $timestamp = strtotime($date); $dateOfBirth = date('Y-m-d',$timestamp); // 1994-03-23 } else { red("No Age is set on profile"); continue; } im getting a match like this March 9, 1993 When i run my script im getting this error [2048] strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Chicago' for 'CST/-6.0/no DST' instead Error: [2048] date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Chicago' for 'CST/-6.0/no DST' instead What could be the problem?? I just upgraded from 5.2.x to 5.3.3 this morning, and am now confronted with the "infamous" Code: [Select] It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for '-5.0/no DST' instead in C:\Inetpub\wwwroot\ATSTest\sys\class\class.calendar.inc.php on line 98 Previously I just let php pull the system time to keep everything accurate with DST. Now that I'm having to use the date.timezone setting in php.ini, how can I tell it to factor in DST, or do I now have to manually perform a calculation in my methods/functions to check and adjust? Or does it automagically recognize the DST by setting it to Code: [Select] date.timezone = America/New_York (yeah, right...what are the odds of *that*? Quote Strict Standards: DateTime::__construct() [datetime.--construct]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Chicago' for 'CDT/-5.0/DST' instead in /home/elliottw/public_html/login/inc/conn.inc.php on line 45 And the code I am using is: $timezone = new DateTimeZone("Europe/London"); $date = new DateTime(); $date->setTimezone($timezone); $dateTime = $date->format('H:i:s d/m/Y'); $sqlDateTime = $date->format('Y-m-d H:i:s'); I've come to the end of my tether. I can't see anything wrong with this, searched Google and I'm starting to go crazy (partly due to the Caffeine and staring at code for 4 hours). Any help would be greatly appreciated! Cheers. I am in need of a script that can detect a visitors timezone with out using geoip and with out the user providing the information. Any help on this or references would be greatly appreciated. hey im writing a page that does the timezones for 5:00 around the world and i found this template the only thing is it didnt include the timezone.php file the js is loading this new Ajax('timezone.php?tz='+String(timezone),{onComplete:tzCLB, method: 'get'}).request(); what it does is retrieves a list of countries from that file i think. How and what would i need to do to make a timezone.php that would get the countries. Thanks How would I change the current timezone used within a php script? The method I usually use, date_default_timezone_set() is undefined on my webhost, so I am trying to find another way. Developing apps is great until I have to start dealing with blasted timezones. For some reason this aspect of it always does my head in. At the moment I'm storing all dates in the DB as GMT with the format Y-m-d H:i:s. I figure it's good to be consistent and store dates in GMT then convert to the users desired timezone. So I allow users to choose there timezone, based off the defined PHP timezones that can be used with the DateTimeZone class. My problem, however, arises with the whole syncing of times. Let's say I post something right now. The date gets stored in in the database as: 2012-04-14 02:35:49 Now I'm in GMT +10 (possibly the greatest of timezones ), so I've set my timezone in my settings as Australia/Melbourne and when displaying date/times locally I do something like this: Code: [Select] public static function local($user, $date, $format = 'F j, Y, h:ia') { $date = new DateTime($date); return $date->setTimezone(new DateTimeZone($user->timezone))->format($format); } So running the stored date above through my method gives me a date like this: April 14, 2012, 12:35pm Awesome. My question is: I noticed that on say, Twitter, when you change your timezone your tweet dates don't change. They remain as the date/time of my actual timezone, regardless of what I set it too. With my implementation however, if I change my timezone to GMT +12 (Fiji) my post is now posted at: April 14, 2012, 02:35pm So is what I'm doing right? My head has about had it. Thanks. |