Jump to content

Search the Community

Showing results for tags 'timezone'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 11 results

  1. I was wondering if there is a way to automatically get a user's timezone? I want to show certain information if the user's current date is less than the expiry date. It works fine if the user is in a default timezone but what if the user is in a different timezone? How I can I make sure I can get their correct current time? date_default_timezone_set('America/New_York'); $expiry_date = trim($row['expiry_date']); $current_date = date('Y-m-d H:i:s'); if($current_date < $expiry_date) { // show data } else { // don't show }
  2. How to automatically detect user timezone name? Like Europe/Stockholm How to automatically detect user locale? Like sv_SE Or its easier to let user to select their timezone and locale?
  3. Hello How can I create a user friendly timezone select menu using PHP, like the one in General account setting of PHPFreaks. thanks !
  4. Hello sorry if the English is not good Is there any way to get client's timezone or hours difference using PHP and JAVASCRIPT so the time is displayed based on the client's timezone, because I've created a small PHP script and when I upload it to the server, the time was displayed based on the server's timezone. Thank's in advance, Have a good day.
  5. Hello, I am trying to convert the Date,Month,Year, Hour:Minutes:Seconds to Timestamp and Timestamp to Date,Month,Year, Hour:Minutes:Seconds . I ve setted the Timezone as Asia/Calcutta in the code . The Code works well when I run in my localhost , But when I run the code in my server located in Dallas,TX,USA the data changes largely . For example : The Timestamp generated for 24-May-2014 00:00:00 is 1400889600 in my localhost (Chennai, India). The Timestamp generated for 24-May-2014 00:00:00 is 1400914800 in my server (Dallas, TX, USA). why this changes occurs even though I ve setted the timezone ? Code: <?php $date = new DateTime(null, new DateTimeZone('Asia/Calcutta')); $ist = ($date->getTimestamp() + $date->getOffset()); echo "<h1>Current Timestamp and Date and Time for India</h1> <b>".$ist.'</b>';echo " ";echo '<b>'.date('D, d M Y H:i:s ',$ist).'+0530</b>'; echo "<br />"; ?> <h1>Timestamp to Date and Time Converter</h1> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="number" name="timestamp_to_dt_timestamp" id="timestamp_to_dt_timestamp" /> <input type="submit" id="submit" name="submit" value="Submit" /> </form> <?php if (isset($_POST['timestamp_to_dt_timestamp'])) { $timestamp_to_dt_timestamp = $_POST['timestamp_to_dt_timestamp']; echo 'Date and Time for the Timestamp :'.$timestamp_to_dt_timestamp.' is : '.date('D, d M Y H:i:s ',$timestamp_to_dt_timestamp); } ?> <h1>Date and Time to TimeStamp Converter</h1> <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> Date (no preceeding zeros): <input type="text" name="dt_to_timestamp__date" id="dt_to_timestamp__date" value="<?php echo date('j',$ist) ?>" /><br /> Month (number): <input type="text" name="dt_to_timestamp__month" id="dt_to_timestamp__month" value="<?php echo date('n',$ist) ?>" /><br /> Year : <input type="text" name="dt_to_timestamp__year" id="dt_to_timestamp__year" value="<?php echo date('Y',$ist) ?>" /><br /> Hours : <input type="text" name="dt_to_timestamp__hours" id="dt_to_timestamp__hours" value="00" /><br /> Minutes : <input type="text" name="dt_to_timestamp__mins" id="dt_to_timestamp__mins" value="00" /><br /> Seconds : <input type="text" name="dt_to_timestamp__sec" id="dt_to_timestamp__sec" value="00" /><br /> <input type="submit" id="submit" name="submit" value="Submit" /> <p>Leave the time field(s) if you don't know the exact time.</p> </form> <?php if (isset($_POST['dt_to_timestamp__date'])) { $dt_to_timestamp__date = $_POST['dt_to_timestamp__date']; } if (isset($_POST['dt_to_timestamp__month'])) { $dt_to_timestamp__month = $_POST['dt_to_timestamp__month']; } if (isset($_POST['dt_to_timestamp__year'])) { $dt_to_timestamp__year = $_POST['dt_to_timestamp__year']; } if (isset($_POST['dt_to_timestamp__hours'])) { $dt_to_timestamp__hours = $_POST['dt_to_timestamp__hours']; } if (isset($_POST['dt_to_timestamp__mins'])) { $dt_to_timestamp__mins = $_POST['dt_to_timestamp__mins']; } if (isset($_POST['dt_to_timestamp__sec'])) { $dt_to_timestamp__sec = $_POST['dt_to_timestamp__sec']; } if (isset($_POST['dt_to_timestamp__date'])) { if (isset($_POST['dt_to_timestamp__month'])) { if (isset($_POST['dt_to_timestamp__year'])) { if (isset($_POST['dt_to_timestamp__hours'])) { if (isset($_POST['dt_to_timestamp__mins'])) { if (isset($_POST['dt_to_timestamp__sec'])) { echo date(mktime($dt_to_timestamp__hours, $dt_to_timestamp__mins, $dt_to_timestamp__sec, $dt_to_timestamp__month, $dt_to_timestamp__date, $dt_to_timestamp__year)); } } } } } } ?> What I am missing ? -Thanks timestamp.php
  6. My php script always returns different times. Example: The current time is 4:33pm and the script returns 11:33am. Then sometimes it is correct, and then randomly switches to something like 7:33pm when it should be 5:33pm. This is my code $time = new DateTime(); $time->setTimezone(new DateTimeZone('America/Chicago')); $time = $time->format('g:i A'); echo $time; I don't know if makes any difference, but I'm renting a server from Go Daddy for my website and it is running Linux. How would I fix this problem? Edit: I'm also having a problem with the "time()" function giving results that are hours off.
  7. Basically my website is worldwide and I need to be able to detect users' time zones and display accurate times. I have this really neat script which used to work flawlessly well until now. It needs a timezone offset which I fetch with javascript and pass through a cookie. if(!empty($_COOKIE['tz']) && $_COOKIE['tz']>=-12 && $_COOKIE['tz']<=13){ $offset = $_COOKIE['tz']; $tz = timezone_name_from_abbr(null, $offset * 3600, true); if($tz === false) $tz = timezone_name_from_abbr(null, $offset * 3600, false); date_default_timezone_set($tz); }else{ date_default_timezone_set('UTC'); } The problem is that currently the timezone I'm testing in is Europe/Helsinki, which is UTC+2 (without daylight savings), but for some reason timezone_name_from_abbr() decides 2*3600 is Europe/Paris. I'm really bad with dates and time zones, I desperately need help, please!
  8. Greetings All Let me begin by saying I am quite new to development and this is my first website. I have learnt a bit of html and css which i have used for the site. I plan on trying to take on some more languages, to delevop my site further in the future, But would like any advice or feedback which could help me with this problem or point me in the right direction. Basically the issue is A part of my site has got a events schedule. The Problem has been the time for the events. i would like to set the time of each event to the Users timezone automatically. Below is basic code of what i have been using. which has been doing this using the scirpt in the <li class="time"> but i need to change the scripts time for every event... The issue being to me 1) Would this not load the script for each event? Slowing down the site loading? 2)How could i possibly tweak the code to remove the script from the <li class="time"> and put it on the page to only load once. Then change it to ie. <li class="time">4:45pm</li> and that automatically changes to the users time from whats entered to there own Timezone from the script being loaded once on the page at the top of the page? <div class="programme"> <ul class="guides"> <a href="domain/xxxxx.php" class="guides" style="display : block; color: black; background-color: transparent;"> <li class="icon"><img src="images/event/????.png" alt="Schedule" width="26" height="27" class="icon"/></li> <li class="time"><script>"src="http://www.thetimezoneconverter.com/js/ttzc.js"></script><script>new TTZC.Widget({ version:'inline', t:'4:45 PM',tz:'London'}).display();</script></li> <li class="game">Team A vs Team B</li> <li class="location">Venue</li> </a> </ul> </div> If that doesnt seem possible, is there some where i can be pointed in to find out more or learn about what languages would be needed to be able to just write out the info in a database like this below which the website can pull down the info and place each variable in the correct place in the html code and css. Basically making it a bit more automated that the code is there and i just need to provide the info. Info(a href), Event Time Game Location xxxxx.php ????.png 06:00pm Team A vs Team B Field B yyyy.php ????.png 07:30pm Player A vs Player B Table 1 zzzz.php ????.png 07:30pm Player A vs Player B Table 2 hhhh.php ????.png 07:30pm Player A vs Player B Table 3 Any help will be greatly appreciated, And being new to this any thing i dont understand in your replies i will try research more info on so i may provide you with the info or understand what you saying. Thank you Kind Regards
  9. Hi all ! I need some help. I'm not a programer but I would like to solve problem with my website by myself. After upgrading PHP on server where is my web page ( www.osmrtnica.net ), i'm getting a lot of errors in my CMS. I hope that someone will have a few minutes to give a look. I have bolded text in code at line 380. And i know that is a lot of text, but what can i do. Thanks in advance. here are the errors: <br /><b>Warning</b>: main() [<a href='function.main'>function.main</a>]: 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/Berlin' for 'CEST/2.0/DST' instead in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /><br /><b>Notice</b>: Use of undefined constant date - assumed 'date' in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /><br /><b>Warning</b>: strtotime() [<a href='function.strtotime'>function.strtotime</a>]: 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/Berlin' for 'CEST/2.0/DST' instead in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /><br /><b>Warning</b>: strtotime() [<a href='function.strtotime'>function.strtotime</a>]: 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/Berlin' for 'CEST/2.0/DST' instead in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /><br /><b>Warning</b>: date() [<a href='function.date'>function.date</a>]: 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/Berlin' for 'CEST/2.0/DST' instead in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /><br /><b>Warning</b>: date() expects parameter 2 to be long, string given in <b>/home2/smiztita/public_html/cms/required/pozdravi_form.php</b> on line <b>380</b><br /> And here is a part of code where error ocurs: <div class="h3" style="height:1px;"> </div> <div style="width:450px; float:left; "> <label for="odobreno">odobreno:</label> <input type="checkbox" class="chk" name="odobreno" id="odobreno" value="1"<?php if ($row['odobreno'] == 't') { ?> checked="checked"<?php } ?> /> <label for="datum">datum:</label> <input type="text" name="datum" id="datum" class="tekst srednji" value="<?php if ($row['datum'] != '') print date('d.m.Y', date.strtotime($row['datum'])); else print date('d.m.Y'); ?>" /> <script type="text/javascript"> <!-- $(document).ready(function(){ $('#datum').datepicker({ mandatory: true, navigationAsDateFormat: true, prevText: '<M', nextText: 'M>', changeMonth: false, monthNames: ['siječanj ','veljača ','ožujak ','travanj ','svibanj ','lipanj ', 'srpanj ','kolovoz ','rujan ', 'listopad ','studeni ','prosinac '], monthNamesShort: ['sij','velj','ožu','tra','svi','lip','srp','kol','ruj','lis','stu','pro'], changeYear: false, weekHeader: '', showWeeks: true, dayNames: ['nedjelja', 'ponedjeljak', 'utorak', 'srijeda', 'četvrtak', 'petak', 'subota'], dayNamesShort: ['ned', 'pon', 'uto', 'srij', 'čet', 'pet', 'sub'], dayNamesMin: ['N', 'P', 'U', 'S','Č', 'P', 'S'], showOtherMonths: true, numberOfMonths: 1, defaultDate: Date(<?= date('Y, m, d', strtotime($row['datum'])); ?>), // default date - Date(yyyy, mm - 1, dd), dateFormat: 'dd.mm.yy', showWeeks: true, firstDay: 1, changeFirstDay: false, closeText: 'X', prevText: '<', nextText: '>', currentText: '' }); }); //--> </script>
  10. Hello, This is my first post on the website. Sorry, I din't went to the introduction section straight up. I am getting the following error on the website. The website was working fine before upgrading the php version. It would be a great help if someone could help me sort this out. I have searched many other forum and this seems to be right place to ask for help. You guys seems to have a giant active community. I don't have much knowledge about the php and stuff and I can't pay my developer to fix this Warning: Unknown: Invalid date.timezone value 'Asia/Calcuttaextension', we selected the timezone 'UTC' for now. in Unknown on line 0 Fatal error: Uncaught exception 'Exception' with message 'DateTimeZone::__construct() expects exactly 1 parameter, 0 given' in /home/user/public_html/fw/init.php:59 Stack trace: #0 /home/user/public_html/fw/init.php(59): DateTimeZone->__construct() #1 /home/user/public_html/fw/init.php(82): fw::connect(Array) #2 /home/user/public_html/application.php(17): fw::config(Array) #3 {main} thrown in /home/user/public_html/fw/init.php on line 59 # Database require FW.'db'.DIRECTORY_SEPARATOR.DB_ADAPTER.'.php'; db::connect(DB_HOST, DB_USER, DB_PASS); db::select_db(DB_NAME); # Timezone if(class_exists('DateTime')) { $date = new DateTime; if(method_exists($date, 'getOffset')) { $offset = $date->getOffset()/60; $minutes = abs($offset); $hours = floor($minutes/60); $minutes -= $hours*60; db::query('SET time_zone="'.sprintf('%+d:%02d', $hours*($minutes<0?-1:1), $minutes).'"'); } } }
  11. Hello, I have a question about datetime. In my website, i have member from canada, usa, france, sweden, belgium..... and a lot of other country Until now, i setup my server for the time GMT, so every date was save at the time of GTM, so every message, profile modification date were always save with that date. In my code: i did: $mDate = new DateTime($profile["DerniereVisite"]); if(!isset($_SESSION["uTimeZome"])) $_SESSION["uTimeZome"]="UTC"; if($_SESSION["uTimeZome"]!="UTC")[b]{ [/b] $tz = new DateTimeZone($_SESSION["uTimeZome"]); $mDate->setTimezone($tz);[b]}[/b] $DerniereVisite = formatTExtDate($mDate->format('Y-m-d G:i:s')); so the $_SESSION["uTimeZome"] keep the good time zone for php for this members, depending on with country he or she is So, with all the test i did, my way works. But now, i change my server for a better server with another compagny. Today, i realize that my server has the localsetting, i mean the server has the date and time for Canada(québec). So i realize that there are some date, that are not converted correctly for some user in other country. So i ask to the administrator for the server to change it to GMT! But his answer was, it's not good to change datetime zone for a server...... that my way to do this is probably wrong and i should check my code...... after some discussion, they finish to change de timezone as i asked. But my question, do i use a good way or a bad way? thanks a lot! Pascal
×
×
  • 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.