[PHP] PHP Time
Hello everyone, I know php time() gives the current unix time which you can format out to a normal date and time. Is there a way to format a specific date and time back to unix time? Thanks for any help.
Re: [PHP] PHP Time
On Mon, Jul 2, 2012 at 4:00 PM, Rob Weissenburger r...@fiberuplink.com wrote: Hello everyone, I know php time() gives the current unix time which you can format out to a normal date and time. Is there a way to format a specific date and time back to unix time? Yup. Look at strtotime() and mktime(): http://php.net/strtotime http://php.net/mktime -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Time
On Mon, 2 Jul 2012, Rob Weissenburger wrote: I know php time() gives the current unix time which you can format out to a normal date and time. Is there a way to format a specific date and time back to unix time? mktime() and strtotime() will do it, depending on the form your time is in. There's probably others. Geoff. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Time
That worked just perfectly. Thank you. -Original Message- From: paras...@gmail.com [mailto:paras...@gmail.com] On Behalf Of Daniel Brown Sent: Monday, July 02, 2012 3:02 PM To: Rob Weissenburger Cc: php-general@lists.php.net Subject: Re: [PHP] PHP Time On Mon, Jul 2, 2012 at 4:00 PM, Rob Weissenburger r...@fiberuplink.com wrote: Hello everyone, I know php time() gives the current unix time which you can format out to a normal date and time. Is there a way to format a specific date and time back to unix time? Yup. Look at strtotime() and mktime(): http://php.net/strtotime http://php.net/mktime -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Time out issue
I am running Windows 2008 R2, IIS 7 I am running into an issue where no matter what I set the script time out to be the server is Giving me a 500 error after like 60 seconds when the process exceeds the configured activity timeout. Here is the example script ? set_time_limit(120); sleep(100); Echo PASSED THE TIME OUT; ? I fully understand this may not be a PHP error but if anyone has ran into this issue with a windows server and can explain in detail how I can adjust the timeout, I would be very grateful. Everything I have read online points to a fcgiext.ini file that does not exist on my server. Anyone know how to help ?
Re: [PHP] Time out issue
On Sat, May 12, 2012 at 9:42 PM, admin ad...@buskirkgraphics.com wrote: I am running Windows 2008 R2, IIS 7 I am running into an issue where no matter what I set the script time out to be the server is Giving me a 500 error after like 60 seconds when the process exceeds the configured activity timeout. Here is the example script ? set_time_limit(120); sleep(100); Echo PASSED THE TIME OUT; ? I fully understand this may not be a PHP error but if anyone has ran into this issue with a windows server and can explain in detail how I can adjust the timeout, I would be very grateful. Everything I have read online points to a fcgiext.ini file that does not exist on my server. Anyone know how to help ? Didn't use windows server in about 10 years (Go linux ;)), but did you try this? http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/44ebc761-ac76-4b44-8894-551c9315af6c.mspx - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Time out issue
-Original Message- From: Matijn Woudt [mailto:tijn...@gmail.com] Sent: Saturday, May 12, 2012 3:54 PM To: admin Cc: php-general@lists.php.net Subject: Re: [PHP] Time out issue On Sat, May 12, 2012 at 9:42 PM, admin ad...@buskirkgraphics.com wrote: I am running Windows 2008 R2, IIS 7 I am running into an issue where no matter what I set the script time out to be the server is Giving me a 500 error after like 60 seconds when the process exceeds the configured activity timeout. Here is the example script ? set_time_limit(120); sleep(100); Echo PASSED THE TIME OUT; ? I fully understand this may not be a PHP error but if anyone has ran into this issue with a windows server and can explain in detail how I can adjust the timeout, I would be very grateful. Everything I have read online points to a fcgiext.ini file that does not exist on my server. Anyone know how to help ? Didn't use windows server in about 10 years (Go linux ;)), but did you try this? http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/44ebc761-ac76-4b44-8894-551c9315af6c.mspx - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I had to get Microsoft on the phone to resolve this issue with IIS and FAST-CGI seems you can adjust the Request Timeout and Activity Timeout within the IIS manager and for some reason no documentation leads you to this point. Sorry to bother issue resolved. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time out issue
On Sat, May 12, 2012 at 10:19 PM, admin ad...@buskirkgraphics.com wrote: -Original Message- From: Matijn Woudt [mailto:tijn...@gmail.com] Sent: Saturday, May 12, 2012 3:54 PM To: admin Cc: php-general@lists.php.net Subject: Re: [PHP] Time out issue On Sat, May 12, 2012 at 9:42 PM, admin ad...@buskirkgraphics.com wrote: I am running Windows 2008 R2, IIS 7 I am running into an issue where no matter what I set the script time out to be the server is Giving me a 500 error after like 60 seconds when the process exceeds the configured activity timeout. Here is the example script ? set_time_limit(120); sleep(100); Echo PASSED THE TIME OUT; ? I fully understand this may not be a PHP error but if anyone has ran into this issue with a windows server and can explain in detail how I can adjust the timeout, I would be very grateful. Everything I have read online points to a fcgiext.ini file that does not exist on my server. Anyone know how to help ? Didn't use windows server in about 10 years (Go linux ;)), but did you try this? http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/44ebc761-ac76-4b44-8894-551c9315af6c.mspx - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I had to get Microsoft on the phone to resolve this issue with IIS and FAST-CGI seems you can adjust the Request Timeout and Activity Timeout within the IIS manager and for some reason no documentation leads you to this point. Sorry to bother issue resolved. Again, Go linux.. Hehehe ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] time/task reporting
Hi, Ok, I admit -I'm lazy! Been asked to make a reporting tool, what and how many hours spent on Possible with a save option, to enable continuously adding during the week, before sending off by mail to manager and one self. Surely I'm not the first person looking at a similar tool, been searching a bit but not found example code to use for adjustment to suite my group needs. Anyone care to share or point me to a site where I can find this? Thanks
Re: [PHP] time/task reporting
On Thu, Mar 1, 2012 at 10:43 AM, Robert Nilsson rob...@myself.com wrote: Hi, Ok, I admit -I'm lazy! Been asked to make a reporting tool, what and how many hours spent on Possible with a save option, to enable continuously adding during the week, before sending off by mail to manager and one self. Surely I'm not the first person looking at a similar tool, been searching a bit but not found example code to use for adjustment to suite my group needs. Anyone care to share or point me to a site where I can find this? Thanks hey, there is something called project hamster for gnome. might give you an idea: http://live.gnome.org/ProjectHamster http://projecthamster.wordpress.com/ https://launchpad.net/hamster-applet
Re: [PHP] time/task reporting
On 1 Mar 2012, at 08:43, Robert Nilsson wrote: Ok, I admit -I'm lazy! Been asked to make a reporting tool, what and how many hours spent on Possible with a save option, to enable continuously adding during the week, before sending off by mail to manager and one self. Surely I'm not the first person looking at a similar tool, been searching a bit but not found example code to use for adjustment to suite my group needs. Anyone care to share or point me to a site where I can find this? This wheel has been invented many times already. Save yourself some time and money and use an existing service: http://www.google.com/search?q=online+time+tracking Add up what your time will cost to develop a solution, double it because your estimate will almost certainly be too low, then double it again to cover maintenance for the first year, and compare that figure to what a SaaS solution will cost for one year. Unless your requirements are sufficiently different to that which already exists, or you want to develop this as a learning experience, grab a wheel off the shelf. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time zone in date function
On 31/01/2012, at 2:55 PM, Ron Piggott wrote: On my clients account when I use “echo date(‘D, d M Y H:i:s');” the output is 5 hours ahead of us. How do I change it to my local time? Is there a way to specify “Eastern” time zone? I expect this would work: echo date(‘D, d M Y H:i:s' , ( strtotime( date(‘D, d M Y H:i:s') – 21600 ) ) ); I would prefer to specify Eastern time, so if the web host changes a server setting it will remain in Eastern time zone. Ron Ron Piggott You can set the timezone for your script using date_default_timezone_set() http://php.net/manual/en/function.date-default-timezone-set.php --- Simon Welsh Admin of http://simon.geek.nz/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Time zones are spinning my brain
Help. I'm using PayPal's API to get a report of all the yesterday's transactions. I'm in California, and I define yesterday as California's yesterday, midnight to midnight. PayPal wants the STARTDATE and ENDDATE provided in UTC/GMT. I'm building and testing my report using this: $start = gmdate('Y-m-d\TH:i:s.00\Z', strtotime(yesterday 00:00:00)); $end = gmdate('Y-m-d\TH:i:s.00\Z', strtotime(yesterday 23:59:59)); which produces: 2011-06-28T07:00:00.00Z 2011-06-29T06:59:59.00Z I think this is right, since it's 7 hours off California time, but I just need someone to double check my spinning head. Will this give me the PayPal transactions that arrived during California's yesterday, or do I need to change something? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time zones are spinning my brain
On 29 June 2011 17:09, Brian Dunning br...@briandunning.com wrote: Help. I'm using PayPal's API to get a report of all the yesterday's transactions. I'm in California, and I define yesterday as California's yesterday, midnight to midnight. PayPal wants the STARTDATE and ENDDATE provided in UTC/GMT. I'm building and testing my report using this: $start = gmdate('Y-m-d\TH:i:s.00\Z', strtotime(yesterday 00:00:00)); $end = gmdate('Y-m-d\TH:i:s.00\Z', strtotime(yesterday 23:59:59)); which produces: 2011-06-28T07:00:00.00Z 2011-06-29T06:59:59.00Z I think this is right, since it's 7 hours off California time, but I just need someone to double check my spinning head. Will this give me the PayPal transactions that arrived during California's yesterday, or do I need to change something? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Something like this ? ?php $o_Start = new DateTime('00:00:00.000', $o_CalifTZ = new DateTimeZone('America/Los_Angeles')); $o_End = new DateTime('23:59:59.999', $o_CalifTZ); echo date('Y-m-d\TH:i:s.00\Z', $o_Start-getTimestamp()), ' to ', date('Y-m-d\TH:i:s.99\Z', $o_End-getTimestamp()), PHP_EOL; And UTC is not the same as GMT. Ish. GMT is only valid for 6 months of the year. Then, due to DST, it becomes BST. UTC is just UTC. Also, your DST may not be on the same day as GMT-BST. Using the timezone America/Los_Angeles holds all the various shifts in DST and offset that have been recorded, so you can use current local time (shifted with DST just like you would read off your watch of PC) with that timezone and PHP can work out what the timestamp is. It sounds a little messy, but the TLA timezones aren't always sufficient. Derick did a really good talk about this a couple of years ago for php|Architect. I'm sure there's a video somewhere of it. All makes perfect sense in the end. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time zones are spinning my brain
On Wed, 29 Jun 2011, Brian Dunning wrote: $start = gmdate('Y-m-d\TH:i:s.00\Z', strtotime(yesterday 00:00:00)); $end = gmdate('Y-m-d\TH:i:s.00\Z', strtotime(yesterday 23:59:59)); I think this is right, since it's 7 hours off California time, but I just need someone to double check my spinning head. Will this give me the PayPal transactions that arrived during California's yesterday, or do I need to change something? Assuming your timezone is set to California time ( date_default_timezone_set ('America/Los_Angeles') ), then yes. Geoff. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: [PHP] Time zones are spinning my brain
On 29 Jun 2011 at 17:25, Richard Quadling rquadl...@gmail.com wrote: And UTC is not the same as GMT. Ish. Yes it is. GMT is only valid for 6 months of the year. Then, due to DST, it becomes BST. No, the UK is on GMT for 5 months a year and then on BST (GMT+1) for 7 months. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time zones are spinning my brain
On Wed, 29 Jun 2011, Richard Quadling wrote: And UTC is not the same as GMT. Ish. GMT is only valid for 6 months of the year. Then, due to DST, it becomes BST. UTC is just UTC. This is incorrect. For all practical purposes, GMT and UTC are the same. The fact that the time in Greenwich is not GMT/UTC for half the year is not relevant. http://www.diffen.com/difference/GMT_vs_UTC All the GM* functions (gmdate, gmstrftime, etc) are intended for dealing with Universal Co-ordinated Time. As a side note, there is (or at least was) no gmstrtotime function. I get around this by putting + at the end of the string. HTH, Geoff. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time zones are spinning my brain
Thanks everyone. It seems to be working correctly. You gave me some extra peace of mind. I did set the date_default_timezone_set('America/Los_Angeles') but it looks like that was in the defaults anyway. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time zones are spinning my brain
On Wed, 29 Jun 2011, Brian Dunning wrote: Thanks everyone. It seems to be working correctly. You gave me some extra peace of mind. I did set the date_default_timezone_set('America/Los_Angeles') but it looks like that was in the defaults anyway. :-) It probably is if this is where your site is hosted. But all you need to do is change hosting providers to one somewhere else, or for someone who's not careful to mess something up on the system, and the script will break all because you assumed it would always be right. So better to set it and know it's right. Geoff. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time zone ignored (both via ini or in code)
On Tue, Nov 2, 2010 at 12:29 AM, Nathan Nobbe quickshif...@gmail.com wrote: a few thoughts, 1. set error_reporting to E_ALL to see if the engine is trying to tell you something you may be overlooking Sorry, failed to mention that I did this, and it says nothing. 2. for grins, maybe see if the TZ environment variable is set on your system var_dump(getenv('TZ')); I didn't post the phpinfo() output originally but had checked and no, TZ isn't set. 3. another test would be to set date.timezone to something else and see if date_default_timezone_get() returns that new value, which would indicate it's falling through to the third option in the precedence chain. AHA! I had tried checking validity by setting a BOGUS time zone (which showed that it was taking effect), but I had not tried checking by setting an alternate VALID time zone. Guess what? It works. If I set it to America/Denver, I get correct output. Thus, something is corrupt in the timezone DB itself (which I believe is internal to PHP from what I understand from the threads I've read). America/Chicago is completely broken but America/Denver works just fine. Incidentally, I have noticed that CentOS is completely broken in their tz distro. Every time it updates, it includes a US/Central file that is completely invalid. This has persisted for months--at the OS level I've fixed it by copying in a valid US/Central file from another box. But doing that does not fix PHP (tried that just now)--which again I'd expect it not to anyway, since I believe PHP (as of PHP5) has an internal timezone DB. But I tried it just in case. So now I suppose the thread becomes: how do I get a valid US/Central (America/Chicago) timezone in PHP5? Thanks much, Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time zone ignored (both via ini or in code)
On Tue, Nov 2, 2010 at 7:52 AM, Dan Yost yod...@gmail.com wrote: So now I suppose the thread becomes: how do I get a valid US/Central (America/Chicago) timezone in PHP5? give the timezonedb extension a shot http://pecl.php.net/package/timezonedb -nathan
Re: [PHP] time zone ignored (both via ini or in code)
On Tue, Nov 2, 2010 at 9:19 AM, Nathan Nobbe quickshif...@gmail.com wrote: On Tue, Nov 2, 2010 at 7:52 AM, Dan Yost yod...@gmail.com wrote: So now I suppose the thread becomes: how do I get a valid US/Central (America/Chicago) timezone in PHP5? give the timezonedb extension a shot http://pecl.php.net/package/timezonedb Tried it, no change. It is still impossible to get simple CENTRAL timezone output. This is maddening. Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time zone ignored (both via ini or in code)
On Tue, Nov 2, 2010 at 8:44 AM, Dan Yost yod...@gmail.com wrote: On Tue, Nov 2, 2010 at 9:19 AM, Nathan Nobbe quickshif...@gmail.com wrote: On Tue, Nov 2, 2010 at 7:52 AM, Dan Yost yod...@gmail.com wrote: So now I suppose the thread becomes: how do I get a valid US/Central (America/Chicago) timezone in PHP5? give the timezonedb extension a shot http://pecl.php.net/package/timezonedb Tried it, no change. It is still impossible to get simple CENTRAL timezone output. This is maddening. That's really weird since I'm sure php has its own timezone db, and it sounds like that's where PHP is getting it if you saw the correct output after switching date.timezone to America/Denver. What about trying date_default_timezone_set() ? -nathan
Re: [PHP] time zone ignored (both via ini or in code)
On Tue, Nov 2, 2010 at 11:02 AM, Nathan Nobbe quickshif...@gmail.com wrote: So now I suppose the thread becomes: how do I get a valid US/Central (America/Chicago) timezone in PHP5? give the timezonedb extension a shot http://pecl.php.net/package/timezonedb Tried it, no change. It is still impossible to get simple CENTRAL timezone output. This is maddening. That's really weird since I'm sure php has its own timezone db, and it sounds like that's where PHP is getting it if you saw the correct output after switching date.timezone to America/Denver. What about trying date_default_timezone_set() ? I had tried that originally too. It does set the timezone correctly, but then again so does the ini set. So the timezone does get set to America/Chicago with a date_default_timezone_set(), and then PHP shanks from there, showing UTC. It seems certain that the timezone *does* get set to America/Chicago (via multiple methods), and that America/Chicago *itself* is corrupt in PHP--and that's even with timezonedb installed. Now everybody knows Chicago is full of corruption, but at least the clocks aren't, right? Surely there are bizillions of others out there running this combination of software in the Central time zone! Yet it's as if nobody else has corrupt timezone DB records (be they internal or via timezonedb) except me. And I can't help but notice how CentOS (tzdata package) is also corrupt, every single time it gets updated, on the Central zone but no others. Obviously these should be entirely separate issues, but somebody out there has it out for the Central time zone. Probably a Yankees fan. Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time zone ignored (both via ini or in code)
On Tue, Nov 2, 2010 at 10:11 AM, Dan Yost yod...@gmail.com wrote: On Tue, Nov 2, 2010 at 11:02 AM, Nathan Nobbe quickshif...@gmail.com wrote: So now I suppose the thread becomes: how do I get a valid US/Central (America/Chicago) timezone in PHP5? give the timezonedb extension a shot http://pecl.php.net/package/timezonedb Tried it, no change. It is still impossible to get simple CENTRAL timezone output. This is maddening. That's really weird since I'm sure php has its own timezone db, and it sounds like that's where PHP is getting it if you saw the correct output after switching date.timezone to America/Denver. What about trying date_default_timezone_set() ? I had tried that originally too. It does set the timezone correctly, but then again so does the ini set. So the timezone does get set to America/Chicago with a date_default_timezone_set(), and then PHP shanks from there, showing UTC. It seems certain that the timezone *does* get set to America/Chicago (via multiple methods), and that America/Chicago *itself* is corrupt in PHP--and that's even with timezonedb installed. Now everybody knows Chicago is full of corruption, but at least the clocks aren't, right? Surely there are bizillions of others out there running this combination of software in the Central time zone! Yet it's as if nobody else has corrupt timezone DB records (be they internal or via timezonedb) except me. And I can't help but notice how CentOS (tzdata package) is also corrupt, every single time it gets updated, on the Central zone but no others. Obviously these should be entirely separate issues, but somebody out there has it out for the Central time zone. Probably a Yankees fan. dude at this point i dont want to sound too much like a troll, but php 5.1 is some really old software. frankly this is why i chose not to run on centos during my evaluation of it. i understand the concept behind running proven stable software, but i think centos is taking that notion to the extreme. i would probly try building a more recent version of php from source and see if that helps. -nathan
Re: [PHP] time zone ignored (both via ini or in code)
On Tue, Nov 2, 2010 at 10:37 AM, Nathan Nobbe quickshif...@gmail.comwrote: dude at this point i dont want to sound too much like a troll, but php 5.1 is some really old software. frankly this is why i chose not to run on centos during my evaluation of it. i understand the concept behind running proven stable software, but i think centos is taking that notion to the extreme. i would probly try building a more recent version of php from source and see if that helps. yeah, we have one centos box left on our network atm, 5.2 $ cat /etc/redhat-release CentOS release 5.2 (Final) php 5.2.6 $ php -v PHP 5.2.6 (cli) (built: May 5 2008 14:41:03) Copyright (c) 1997-2008 The PHP Group looks like if i set the timezone explicitly the date functions are working correctly (obviously though im not sure if this is a 5.1 vs 5.2 issue, just saying :D) php echo Br . strftime(%D %T %z %Z) . br; Br11/02/10 10:40:12 -0600 MDTbr php date_default_timezone_set('America/Chicago'); php echo Br . strftime(%D %T %z %Z) . br; Br11/02/10 11:40:53 -0500 CDTbr -nathan
Re: [PHP] time zone ignored (both via ini or in code)
On Tue, Nov 2, 2010 at 11:37 AM, Nathan Nobbe quickshif...@gmail.com wrote: dude at this point i dont want to sound too much like a troll, but php 5.1 is some really old software. frankly this is why i chose not to run on centos during my evaluation of it. i understand the concept behind running proven stable software, but i think centos is taking that notion to the extreme. i would probly try building a more recent version of php from source and see if that helps. That's OK, I knew this was coming. It's been a real struggle to be deploying something so old, yet CentOS insists on nothing but 5.1 in the packages unless you resort to some volatile repositories, which kind of defeats the purpose (in my case, that is). I used to always go with source directly but was really hoping to go the somewhat-brainless auto-update route, sticking to yum packages and all that. At risk of sending this thread too far down an OS-specific path, can anybody in the CentOS+PHP world comment on yum packages, 5.1, and this actual issue? (In the very beginning I scoured the Net, thinking surely 5.1.6 can't be the standard on CentOS, but kept running into the either go from source yourself or use volatile repositories claims, which aren't good in an enterprise case, though I realize using source isn't bad from that standpoint). Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] time zone ignored (both via ini or in code)
Greetings, I've looked through a number of different archived threads (some rather heated) and samples as well, but clearly I'm just missing something. PHP 5.1.6 CentOS release 5.5 (Final) My server is in Central Time (US). We do observe DST. I noticed functions like strftime() display UTC time. So I undertook fixing this. I read several threads about setting date.timezone in php.ini, and arguments for/against different timezone methods. But in my case I see no reason why setting the timezone in php.ini would hurt us--we can live with that. And yet: [...@ez2 html 13:47:20]$ date Mon Nov 1 13:50:05 CDT 2010 Good. [...@ez2 html 13:50:05]$ grep -i timezone /etc/php.ini date.timezone = America/Chicago Good--and yes, Apache was restarted. So far, we're Central, life is good. Let's hit PHP now: ? if (date_default_timezone_get()) { echo 'date_default_timezone_get: ' . date_default_timezone_get() . 'br /'; } if (ini_get('date.timezone')) { echo 'date.timezone: ' . ini_get('date.timezone'); } echo Br; $localtime = localtime(); $localtime_assoc = localtime(time(), true); print_r($localtime); print_r($localtime_assoc); echo Br . strftime(%D %T %z %Z) . br; ? Which produces: date_default_timezone_get: America/Chicago date.timezone: America/Chicago Array ( [0] = 14 [1] = 51 [2] = 18 [3] = 1 [4] = 10 [5] = 110 [6] = 1 [7] = 304 [8] = 0 ) Array ( [tm_sec] = 14 [tm_min] = 51 [tm_hour] = 18 [tm_mday] = 1 [tm_mon] = 10 [tm_year] = 110 [tm_wday] = 1 [tm_yday] = 304 [tm_isdst] = 0 ) 11/01/10 18:51:14 + UTC Timezone is America/Chicago, yet date functions completely ignore this and continue to display UTC. Please help me understand where I'm blind here. Thanks, Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time zone ignored (both via ini or in code)
On Mon, Nov 1, 2010 at 12:54 PM, Dan Yost yod...@gmail.com wrote: Greetings, I've looked through a number of different archived threads (some rather heated) and samples as well, but clearly I'm just missing something. PHP 5.1.6 CentOS release 5.5 (Final) My server is in Central Time (US). We do observe DST. I noticed functions like strftime() display UTC time. So I undertook fixing this. I read several threads about setting date.timezone in php.ini, and arguments for/against different timezone methods. But in my case I see no reason why setting the timezone in php.ini would hurt us--we can live with that. And yet: [...@ez2 html 13:47:20]$ date Mon Nov 1 13:50:05 CDT 2010 Good. [...@ez2 html 13:50:05]$ grep -i timezone /etc/php.ini date.timezone = America/Chicago Good--and yes, Apache was restarted. So far, we're Central, life is good. Let's hit PHP now: ? if (date_default_timezone_get()) { echo 'date_default_timezone_get: ' . date_default_timezone_get() . 'br /'; } if (ini_get('date.timezone')) { echo 'date.timezone: ' . ini_get('date.timezone'); } echo Br; $localtime = localtime(); $localtime_assoc = localtime(time(), true); print_r($localtime); print_r($localtime_assoc); echo Br . strftime(%D %T %z %Z) . br; ? Which produces: date_default_timezone_get: America/Chicago date.timezone: America/Chicago Array ( [0] = 14 [1] = 51 [2] = 18 [3] = 1 [4] = 10 [5] = 110 [6] = 1 [7] = 304 [8] = 0 ) Array ( [tm_sec] = 14 [tm_min] = 51 [tm_hour] = 18 [tm_mday] = 1 [tm_mon] = 10 [tm_year] = 110 [tm_wday] = 1 [tm_yday] = 304 [tm_isdst] = 0 ) 11/01/10 18:51:14 + UTC Timezone is America/Chicago, yet date functions completely ignore this and continue to display UTC. Please help me understand where I'm blind here. a few thoughts, 1. set error_reporting to E_ALL to see if the engine is trying to tell you something you may be overlooking 2. for grins, maybe see if the TZ environment variable is set on your system var_dump(getenv('TZ')); 3. another test would be to set date.timezone to something else and see if date_default_timezone_get() returns that new value, which would indicate it's falling through to the third option in the precedence chain. lastly you might see if the calling date_default_timezone_set() does the trick. -nathan
[PHP] Time Problem: always ten past xx
Hey everybody, I've got a strange problem. Using PHP5.3 on my MacBook. There is a script, which handles input from user, in this case a date and time. So I get for example 10:30 and 06.10.2009. Standard german time format. Now I try to get the correct timestamp: $time = strtotime(06.10.2009 10:30); var_dump($time); var_dump(strftime(%d.%m.%Y %H:%m,$time)); But the result is as int 1254817800 string '06.10.2009 10:10' (length=16) The minutes are always 10, no matter what time I get. Anyone a clue? Thanks, Mattes P.S.: default timezone is set to date_default_timezone_set('Europe/Berlin'); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Time Problem: always ten past xx
Hi, That's because %m is month, what you need is %M for minute (note uppercase). Check out http://php.net/strftime HTH J -Original Message- From: Matthias Laug [mailto:matthias.l...@gmail.com] Sent: 06 October 2009 08:53 To: php-general@lists.php.net Subject: [PHP] Time Problem: always ten past xx Hey everybody, I've got a strange problem. Using PHP5.3 on my MacBook. There is a script, which handles input from user, in this case a date and time. So I get for example 10:30 and 06.10.2009. Standard german time format. Now I try to get the correct timestamp: $time = strtotime(06.10.2009 10:30); var_dump($time); var_dump(strftime(%d.%m.%Y %H:%m,$time)); But the result is as int 1254817800 string '06.10.2009 10:10' (length=16) The minutes are always 10, no matter what time I get. Anyone a clue? Thanks, Mattes P.S.: default timezone is set to date_default_timezone_set('Europe/Berlin'); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Time Problem: always ten past xx
You also write the answer var_dump(strftime(%d.%m.%Y %H:%m,$time)); there are 2 %m you see? %m is month :) for minute use %i -Original Message- From: Matthias Laug [mailto:matthias.l...@gmail.com] Sent: Tuesday, October 06, 2009 10:53 AM To: php-general@lists.php.net Subject: [PHP] Time Problem: always ten past xx Hey everybody, I've got a strange problem. Using PHP5.3 on my MacBook. There is a script, which handles input from user, in this case a date and time. So I get for example 10:30 and 06.10.2009. Standard german time format. Now I try to get the correct timestamp: $time = strtotime(06.10.2009 10:30); var_dump($time); var_dump(strftime(%d.%m.%Y %H:%m,$time)); But the result is as int 1254817800 string '06.10.2009 10:10' (length=16) The minutes are always 10, no matter what time I get. Anyone a clue? Thanks, Mattes P.S.: default timezone is set to date_default_timezone_set('Europe/Berlin'); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Bu mesaj ve ekleri, mesajda g?nderildi?i belirtilen ki?i/ki?ilere ?zeldir ve gizlidir. Size yanl??l?kla ula?m??sa l?tfen g?nderen kisiyi bilgilendiriniz ve mesaj? sisteminizden siliniz. Mesaj ve eklerinin i?eri?i ile ilgili olarak ?irketimizin herhangi bir hukuki sorumlulu?u bulunmamaktad?r. ?irketimiz mesaj?n ve bilgilerinin size de?i?ikli?e u?rayarak veya ge? ula?mas?ndan, b?t?nl???n?n ve gizlili?inin korunamamas?ndan, vir?s i?ermesinden ve bilgisayar sisteminize verebilece?i herhangi bir zarardan sorumlu tutulamaz. This message and attachments are confidential and intended for the individual(s) stated in this message. If you received this message in error, please immediately notify the sender and delete it from your system. Our company has no legal responsibility for the contents of the message and its attachments. Our company shall have no liability for any changes or late receiving, loss of integrity and confidentiality, viruses and any damages caused in anyway to your computer system.
Re: [PHP] Time Problem: always ten past xx
argh, why do I always stick to the stupid questions :( sorry Am 06.10.2009 um 10:03 schrieb Mert Oztekin: You also write the answer var_dump(strftime(%d.%m.%Y %H:%m,$time)); there are 2 %m you see? %m is month :) for minute use %i -Original Message- From: Matthias Laug [mailto:matthias.l...@gmail.com] Sent: Tuesday, October 06, 2009 10:53 AM To: php-general@lists.php.net Subject: [PHP] Time Problem: always ten past xx Hey everybody, I've got a strange problem. Using PHP5.3 on my MacBook. There is a script, which handles input from user, in this case a date and time. So I get for example 10:30 and 06.10.2009. Standard german time format. Now I try to get the correct timestamp: $time = strtotime(06.10.2009 10:30); var_dump($time); var_dump(strftime(%d.%m.%Y %H:%m,$time)); But the result is as int 1254817800 string '06.10.2009 10:10' (length=16) The minutes are always 10, no matter what time I get. Anyone a clue? Thanks, Mattes P.S.: default timezone is set to date_default_timezone_set('Europe/Berlin'); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Bu mesaj ve ekleri, mesajda gönderildiği belirtilen kişi/kişilere özeldir ve gizlidir. Size yanlışlıkla ulaşmışsa lütfen gönderen kisiyi bilgilendiriniz ve mesajı sisteminizden siliniz. Mesaj ve eklerinin içeriği ile ilgili olarak şirketimizin herhangi bir hukuki sorumluluğu bulunmamaktadır. Şirketimiz mesajın ve bilgilerinin size değişikliğe uğrayarak veya geç ulaşmasından, bütünlüğünün ve gizliliğinin korunamamasından, virüs içermesinden ve bilgisayar sisteminize verebileceği herhangi bir zarardan sorumlu tutulamaz. This message and attachments are confidential and intended for the individual(s) stated in this message. If you received this message in error, please immediately notify the sender and delete it from your system. Our company has no legal responsibility for the contents of the message and its attachments. Our company shall have no liability for any changes or late receiving, loss of integrity and confidentiality, viruses and any damages caused in anyway to your computer system. Matthias Laug Schillerstraße 36 10627 Berlin Tel.: 0176 / 20 14 21 63 eMail: matthias.l...@gmail.com
RE: [PHP] Time Problem: always ten past xx
Jason, %M is also month: Month --- --- F A full textual representation of a month, such as January or March January through December m Numeric representation of a month, with leading zeros 01 through 12 M A short textual representation of a month, three letters Jan through Dec n Numeric representation of a month, without leading zeros 1 through 12 t Number of days in the given month 28 through 31 Time --- --- i Minutes with leading zeros 00 to 59 http://tr.php.net/manual/en/function.date.php -Original Message- From: Jason [mailto:networkad...@emarket2.com] Sent: Tuesday, October 06, 2009 11:04 AM To: 'Matthias Laug'; php-general@lists.php.net Subject: RE: [PHP] Time Problem: always ten past xx Hi, That's because %m is month, what you need is %M for minute (note uppercase). Check out http://php.net/strftime HTH J -Original Message- From: Matthias Laug [mailto:matthias.l...@gmail.com] Sent: 06 October 2009 08:53 To: php-general@lists.php.net Subject: [PHP] Time Problem: always ten past xx Hey everybody, I've got a strange problem. Using PHP5.3 on my MacBook. There is a script, which handles input from user, in this case a date and time. So I get for example 10:30 and 06.10.2009. Standard german time format. Now I try to get the correct timestamp: $time = strtotime(06.10.2009 10:30); var_dump($time); var_dump(strftime(%d.%m.%Y %H:%m,$time)); But the result is as int 1254817800 string '06.10.2009 10:10' (length=16) The minutes are always 10, no matter what time I get. Anyone a clue? Thanks, Mattes P.S.: default timezone is set to date_default_timezone_set('Europe/Berlin'); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Bu mesaj ve ekleri, mesajda g?nderildi?i belirtilen ki?i/ki?ilere ?zeldir ve gizlidir. Size yanl??l?kla ula?m??sa l?tfen g?nderen kisiyi bilgilendiriniz ve mesaj? sisteminizden siliniz. Mesaj ve eklerinin i?eri?i ile ilgili olarak ?irketimizin herhangi bir hukuki sorumlulu?u bulunmamaktad?r. ?irketimiz mesaj?n ve bilgilerinin size de?i?ikli?e u?rayarak veya ge? ula?mas?ndan, b?t?nl???n?n ve gizlili?inin korunamamas?ndan, vir?s i?ermesinden ve bilgisayar sisteminize verebilece?i herhangi bir zarardan sorumlu tutulamaz. This message and attachments are confidential and intended for the individual(s) stated in this message. If you received this message in error, please immediately notify the sender and delete it from your system. Our company has no legal responsibility for the contents of the message and its attachments. Our company shall have no liability for any changes or late receiving, loss of integrity and confidentiality, viruses and any damages caused in anyway to your computer system.
RE: [PHP] Time Problem: always ten past xx
My mistake, I thought it was date() now strftime() Sorry (why do php developers create two different standarts for such similiar functions???☺ ) _ From: Mert Oztekin Sent: Tuesday, October 06, 2009 11:07 AM To: 'Jason'; 'Matthias Laug'; php-general@lists.php.net Subject: RE: [PHP] Time Problem: always ten past xx Jason, %M is also month: Month --- --- F A full textual representation of a month, such as January or March January through December m Numeric representation of a month, with leading zeros 01 through 12 M A short textual representation of a month, three letters Jan through Dec n Numeric representation of a month, without leading zeros 1 through 12 t Number of days in the given month 28 through 31 Time --- --- i Minutes with leading zeros 00 to 59 http://tr.php.net/manual/en/function.date.php -Original Message- From: Jason [mailto:networkad...@emarket2.com] Sent: Tuesday, October 06, 2009 11:04 AM To: 'Matthias Laug'; php-general@lists.php.net Subject: RE: [PHP] Time Problem: always ten past xx Hi, That's because %m is month, what you need is %M for minute (note uppercase). Check out http://php.net/strftime HTH J -Original Message- From: Matthias Laug [mailto:matthias.l...@gmail.com] Sent: 06 October 2009 08:53 To: php-general@lists.php.net Subject: [PHP] Time Problem: always ten past xx Hey everybody, I've got a strange problem. Using PHP5.3 on my MacBook. There is a script, which handles input from user, in this case a date and time. So I get for example 10:30 and 06.10.2009. Standard german time format. Now I try to get the correct timestamp: $time = strtotime(06.10.2009 10:30); var_dump($time); var_dump(strftime(%d.%m.%Y %H:%m,$time)); But the result is as int 1254817800 string '06.10.2009 10:10' (length=16) The minutes are always 10, no matter what time I get. Anyone a clue? Thanks, Mattes P.S.: default timezone is set to date_default_timezone_set('Europe/Berlin'); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Bu mesaj ve ekleri, mesajda gönderildiği belirtilen kişi/kişilere özeldir ve gizlidir. Size yanlışlıkla ulaşmışsa lütfen gönderen kisiyi bilgilendiriniz ve mesajı sisteminizden siliniz. Mesaj ve eklerinin içeriği ile ilgili olarak şirketimizin herhangi bir hukuki sorumluluğu bulunmamaktadır. Şirketimiz mesajın ve bilgilerinin size değişikliğe uğrayarak veya geç ulaşmasından, bütünlüğünün ve gizliliğinin korunamamasından, virüs içermesinden ve bilgisayar sisteminize verebileceği herhangi bir zarardan sorumlu tutulamaz. This message and attachments are confidential and intended for the individual(s) stated in this message. If you received this message in error, please immediately notify the sender and delete it from your system. Our company has no legal responsibility for the contents of the message and its attachments. Our company shall have no liability for any changes or late receiving, loss of integrity and confidentiality, viruses and any damages caused in anyway to your computer system.
RE: [PHP] Time Problem: always ten past xx
Hi Mert, But we're not talking about date() here, we're talking strftime(). According to the manual %i doesn't do anything in strftime(). Closest match is %I which is 12-hour format for hours. HTH J -Original Message- From: Mert Oztekin [mailto:mozte...@anadolusigorta.com.tr] Sent: 06 October 2009 09:07 To: 'Jason'; 'Matthias Laug'; php-general@lists.php.net Subject: RE: [PHP] Time Problem: always ten past xx Jason, %M is also month: Month --- --- F A full textual representation of a month, such as January or March January through December m Numeric representation of a month, with leading zeros 01 through 12 M A short textual representation of a month, three letters Jan through Dec n Numeric representation of a month, without leading zeros 1 through 12 t Number of days in the given month 28 through 31 Time --- --- i Minutes with leading zeros 00 to 59 http://tr.php.net/manual/en/function.date.php -Original Message- From: Jason [mailto:networkad...@emarket2.com] Sent: Tuesday, October 06, 2009 11:04 AM To: 'Matthias Laug'; php-general@lists.php.net Subject: RE: [PHP] Time Problem: always ten past xx Hi, That's because %m is month, what you need is %M for minute (note uppercase). Check out http://php.net/strftime HTH J -Original Message- From: Matthias Laug [mailto:matthias.l...@gmail.com] Sent: 06 October 2009 08:53 To: php-general@lists.php.net Subject: [PHP] Time Problem: always ten past xx Hey everybody, I've got a strange problem. Using PHP5.3 on my MacBook. There is a script, which handles input from user, in this case a date and time. So I get for example 10:30 and 06.10.2009. Standard german time format. Now I try to get the correct timestamp: $time = strtotime(06.10.2009 10:30); var_dump($time); var_dump(strftime(%d.%m.%Y %H:%m,$time)); But the result is as int 1254817800 string '06.10.2009 10:10' (length=16) The minutes are always 10, no matter what time I get. Anyone a clue? Thanks, Mattes P.S.: default timezone is set to date_default_timezone_set('Europe/Berlin'); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Bu mesaj ve ekleri, mesajda g?nderildi?i belirtilen ki?i/ki?ilere ?zeldir ve gizlidir. Size yanl??l?kla ula?m??sa l?tfen g?nderen kisiyi bilgilendiriniz ve mesaj? sisteminizden siliniz. Mesaj ve eklerinin i?eri?i ile ilgili olarak ?irketimizin herhangi bir hukuki sorumlulu?u bulunmamaktad?r. ?irketimiz mesaj?n ve bilgilerinin size de?i?ikli?e u?rayarak veya ge? ula?mas?ndan, b?t?nl???n?n ve gizlili?inin korunamamas?ndan, vir?s i?ermesinden ve bilgisayar sisteminize verebilece?i herhangi bir zarardan sorumlu tutulamaz. This message and attachments are confidential and intended for the individual(s) stated in this message. If you received this message in error, please immediately notify the sender and delete it from your system. Our company has no legal responsibility for the contents of the message and its attachments. Our company shall have no liability for any changes or late receiving, loss of integrity and confidentiality, viruses and any damages caused in anyway to your computer system. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time Problem: always ten past xx
On 10/6/09 4:16 AM, Mert Oztekin mozte...@anadolusigorta.com.tr wrote: My mistake, I thought it was date() now strftime() Sorry (why do php developers create two different standarts for such similiar functions???☺ ) it's traditional to do so. it reminds me of the bit about subtly incompatible shells in unix from Real Programmers Don't Use Pascal: Even Unix might not be as bad on Real Programmers as it once was. The latest release of Unix has the potential of an operating system worthy of any Real Programmer-- two different and subtly incompatible user interfaces, an arcane and complicated teletype driver, virtual memory. If you ignore the fact that it's structured, even 'C' programming can be appreciated by the Real Programmer: after all, there's no type checking, variable names are seven (ten? eight?) characters long, and the added bonus of the Pointer data type is thrown in-- like having the best parts of Fortran and assembly language in one place. (Not to mention some of the more creative uses for #define.) we could collect a list: gnu make vs bsd make how many subtly different versions of grep are there? but i'm, sure it's been done already and i guess it's off topic. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time Problem: always ten past xx
At 10:07 AM +0200 10/6/09, Matthias Laug wrote: argh, why do I always stick to the stupid questions :( sorry Because with the important questions, you don't need answers. You understand them. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Time keeping in DB
So, obviously not PHP related, but I'm looking for thoughts on the best way to record time sheets in a DB. A time sheet for hours worked per day, not like a time clock where you start and stop. The two possibilities that I have thought of are (these are simplistic, of course I'll be storing references to the user, the project code etc.): 1. One record for each 7 day week (year, week_num, d1, d2, d3, d4, d5, d6, d7) where the dX field holds the hours worked 2. One record for each day (date, hours) -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time keeping in DB
On Wed, 2009-08-05 at 14:18 -0500, Shawn McKenzie wrote: So, obviously not PHP related, but I'm looking for thoughts on the best way to record time sheets in a DB. A time sheet for hours worked per day, not like a time clock where you start and stop. The two possibilities that I have thought of are (these are simplistic, of course I'll be storing references to the user, the project code etc.): 1. One record for each 7 day week (year, week_num, d1, d2, d3, d4, d5, d6, d7) where the dX field holds the hours worked 2. One record for each day (date, hours) -- Thanks! -Shawn http://www.spidean.com I'd go with a record per timesheet, so you might end up with more than one timesheet per day. That way, it's just simple SQL to find out how many hours you've worked on one day, or on one job, etc. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time keeping in DB
You don't mention what DB you're using, but mySQL can be quite a pain when dealing with multiple time zones. Not impossible, but a hassle none the less. Be sure to set aside a place to store this (and another spot for user preferences to keep track of their TZ). Jerry Wilborn jerrywilb...@gmail.com On Wed, Aug 5, 2009 at 2:20 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Wed, 2009-08-05 at 14:18 -0500, Shawn McKenzie wrote: So, obviously not PHP related, but I'm looking for thoughts on the best way to record time sheets in a DB. A time sheet for hours worked per day, not like a time clock where you start and stop. The two possibilities that I have thought of are (these are simplistic, of course I'll be storing references to the user, the project code etc.): 1. One record for each 7 day week (year, week_num, d1, d2, d3, d4, d5, d6, d7) where the dX field holds the hours worked 2. One record for each day (date, hours) -- Thanks! -Shawn http://www.spidean.com I'd go with a record per timesheet, so you might end up with more than one timesheet per day. That way, it's just simple SQL to find out how many hours you've worked on one day, or on one job, etc. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time keeping in DB
Shawn McKenzie nos...@mckenzies.net wrote: So, obviously not PHP related, but I'm looking for thoughts on the best way to record time sheets in a DB. A time sheet for hours worked per day, not like a time clock where you start and stop. The two possibilities that I have thought of are (these are simplistic, of course I'll be storing references to the user, the project code etc.): 1. One record for each 7 day week (year, week_num, d1, d2, d3, d4, d5, d6, d7) where the dX field holds the hours worked 2. One record for each day (date, hours) -- Thanks! -Shawn http://www.spidean.com Depends on what you are looking to do.. Are you also needing to keep whether or not a specific project? If it is regular time/Overtime? It may be easier to set the database up: user,week,day,project,hours,type Then you can query the info/user off that, it should allow you to expand as needed. HTH, Wolf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Time limit on recursive procedure?
I have a recursive procedure, and I set the time limit each time I enter it: function rec_scan($directory, ..) { set_time_limit (1); if (is_dir($new_file)) { rec_scan ($new_file, ) } } The way I read the manual, the timer should be reset each time I call rec_scanl, but I seem to have to set a longer time limit than I would have anticipated, and I wonder if in fact the original time limit still applies to the original invocation? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time limit on recursive procedure?
Clancy wrote: I have a recursive procedure, and I set the time limit each time I enter it: function rec_scan($directory, ..) { set_time_limit (1); if (is_dir($new_file)) { rec_scan ($new_file, ) } } The way I read the manual, the timer should be reset each time I call rec_scanl, You keep calling it so as long as the execution time between each call is 1 second, your script will keep going. /Per -- Per Jessen, Zürich (15.4°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time limit on recursive procedure?
On Sun, 07 Jun 2009 13:04:20 +0200, p...@computer.org (Per Jessen) wrote: Clancy wrote: I have a recursive procedure, and I set the time limit each time I enter it: function rec_scan($directory, ..) { set_time_limit (1); if (is_dir($new_file)) { rec_scan ($new_file, ) } } The way I read the manual, the timer should be reset each time I call rec_scanl, You keep calling it so as long as the execution time between each call is 1 second, your script will keep going. /Per Thanks. That's what I thought. I'm using it to back up my working directory to another drive, and a 3 second limit wasn't long enough, so one of the directories must take longer than I expected to copy. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Time difference desired load
Suggestion on faster solutions for extremely large database. $ledip['started'] = '2009-04-01 13:40:34'; Example time in DB $ledip['touchedlast'] = '2009-04-01 13:41:28'; Example time in DB date('i:s', strtotime($ledip['touchedlast']) - strtotime($ledip['started'])); // Not a desired solution because of its inability to go past the minute correctly I AM AWARE. or concat( truncate( hour( timediff($ledip['touchedlast'],$ledip['started']) ) /24, 0 ) , days , hour( timediff($ledip['touchedlast'],$ledip['started']) ) %24, hours , minute( timediff($ledip['touchedlast'],$ledip['started'] ) ) , minutes , second( timediff($ledip['touchedlast'],$ledip['started'] ) ) , seconds ) as timeleft The results of concat truncate, allows me the flexibility or exacting time differences out past the minute. I am worried that the vastness of the database may cause me a server load or query timeframes that are undesirable as it grows even bigger. Suggestions? * PLEASE Do not reply to this email with your 9 million page thought of how to, or some custom function that you think is all that, I do not care. I am asking for load desired results NOT your take on my code… -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time difference desired load
On Mon, Apr 20, 2009 at 1:38 PM, ad...@buskirkgraphics.com wrote: Suggestion on faster solutions for extremely large database. $ledip['started'] = '2009-04-01 13:40:34'; Example time in DB $ledip['touchedlast'] = '2009-04-01 13:41:28'; Example time in DB date('i:s', strtotime($ledip['touchedlast']) - strtotime($ledip['started'])); // Not a desired solution because of its inability to go past the minute correctly I AM AWARE. or concat( truncate( hour( timediff($ledip['touchedlast'],$ledip['started']) ) /24, 0 ) , days , hour( timediff($ledip['touchedlast'],$ledip['started']) ) %24, hours , minute( timediff($ledip['touchedlast'],$ledip['started'] ) ) , minutes , second( timediff($ledip['touchedlast'],$ledip['started'] ) ) , seconds ) as timeleft The results of concat truncate, allows me the flexibility or exacting time differences out past the minute. I am worried that the vastness of the database may cause me a server load or query timeframes that are undesirable as it grows even bigger. Suggestions? * PLEASE Do not reply to this email with your 9 million page thought of how to, or some custom function that you think is all that, I do not care. I am asking for load desired results NOT your take on my code… -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You are doing a lot of calculation on this combining both PHP and SQL code. How many rows are you affecting with this query at one time? I hate to say it, but this to me is just begging for a unix timestamps, then you can simply deal with the seconds remaining on this counter. -- Bastien Cat, the other other white meat
[PHP] time() TIMER in seconds or just numbers
what does time(); $t1 = time(); { do something } $t2 = time(); $end_time = $t2 - $t1; echo $end_time; what does $end_time represent? how do you determine the next 5 mins? -- Best Wishes willandy.co.uk
Re: [PHP] time() TIMER in seconds or just numbers
2009/3/30 Andrew Williams andrew4willi...@gmail.com: what does time(); $t1 = time(); { do something } $t2 = time(); $end_time = $t2 - $t1; echo $end_time; what does $end_time represent? The number of seconds it took to do something. how do you determine the next 5 mins? Assuming you mean what will time() return in 5 minutes time?... $five_minutes_time = time() + 300; // 300 seconds in 5 minutes If you mean something else please try rephrasing the question. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time() TIMER in seconds or just numbers
2009/3/30 Andrew Williams andrew4willi...@gmail.com: what does time(); $t1 = time(); { do something } $t2 = time(); $end_time = $t2 - $t1; echo $end_time; what does $end_time represent? $end_time is not a great name for it: it's the time (number of seconds) it took to go from $t1 to $t2. $duration might be better. how do you determine the next 5 mins? Eh? time() + 300 is five minutes from now. -- Richard Heyes HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.net (Updated March 14th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time() TIMER in seconds or just numbers
When someone does that, it means the execution time between $t1 and $t2... Att, Igor Escobar systems analyst interface designer www . igorescobar . com On Mon, Mar 30, 2009 at 7:38 AM, Richard Heyes rich...@php.net wrote: 2009/3/30 Andrew Williams andrew4willi...@gmail.com: what does time(); $t1 = time(); { do something } $t2 = time(); $end_time = $t2 - $t1; echo $end_time; what does $end_time represent? $end_time is not a great name for it: it's the time (number of seconds) it took to go from $t1 to $t2. $duration might be better. how do you determine the next 5 mins? Eh? time() + 300 is five minutes from now. -- Richard Heyes HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.net (Updated March 14th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time() TIMER in seconds or just numbers
When someone does that, it means the execution time between $t1 and $t2... Is that for my benefit? Believe it or not, I do know the arcane art of subtraction... -- Richard Heyes HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.net (Updated March 14th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time() TIMER in seconds or just numbers
On Mon, Mar 30, 2009 at 10:47 AM, Richard Heyes rich...@php.net wrote: When someone does that, it means the execution time between $t1 and $t2... Is that for my benefit? Believe it or not, I do know the arcane art of subtraction... I would subtract more often, but sacrificial farm animals and black candles are so hard to come by these days... -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time() TIMER in seconds or just numbers
On Mon, Mar 30, 2009 at 12:05 PM, haliphax halip...@gmail.com wrote: On Mon, Mar 30, 2009 at 10:47 AM, Richard Heyes rich...@php.net wrote: When someone does that, it means the execution time between $t1 and $t2... Is that for my benefit? Believe it or not, I do know the arcane art of subtraction... I would subtract more often, but sacrificial farm animals and black candles are so hard to come by these days... -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I have a couple of managers you can have...they bleat like sheep most of the time any way and don't provide much other than dung... -- Bastien Cat, the other other white meat
Re: [PHP] time() TIMER in seconds or just numbers
On Mon, Mar 30, 2009 at 11:37 AM, Igor Escobar titiolin...@gmail.com wrote: The people use that to measure performance. If you're intersted about that read http://www.igorescobar.com/blog/2009/03/05/benchmarking-de-desempenho-no-php/ (in portuguese, sorry) Regards, Igor Escobar On Mon, Mar 30, 2009 at 1:05 PM, haliphax halip...@gmail.com wrote: On Mon, Mar 30, 2009 at 10:47 AM, Richard Heyes rich...@php.net wrote: When someone does that, it means the execution time between $t1 and $t2... Is that for my benefit? Believe it or not, I do know the arcane art of subtraction... I would subtract more often, but sacrificial farm animals and black candles are so hard to come by these days... Oh, I'm fully aware of what it's for. FYI, microtime() is probably more appropriate, since 1 full second in computer terms is a loong time. ...and I don't speak a lick of Portuguese. -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time() TIMER in seconds or just numbers
Okey, but you understand the purpouse of it? Igor Escobar systems analyst interface designer www . igorescobar . com On Mon, Mar 30, 2009 at 3:42 PM, haliphax halip...@gmail.com wrote: On Mon, Mar 30, 2009 at 11:37 AM, Igor Escobar titiolin...@gmail.com wrote: The people use that to measure performance. If you're intersted about that read http://www.igorescobar.com/blog/2009/03/05/benchmarking-de-desempenho-no-php/ (in portuguese, sorry) Regards, Igor Escobar On Mon, Mar 30, 2009 at 1:05 PM, haliphax halip...@gmail.com wrote: On Mon, Mar 30, 2009 at 10:47 AM, Richard Heyes rich...@php.net wrote: When someone does that, it means the execution time between $t1 and $t2... Is that for my benefit? Believe it or not, I do know the arcane art of subtraction... I would subtract more often, but sacrificial farm animals and black candles are so hard to come by these days... Oh, I'm fully aware of what it's for. FYI, microtime() is probably more appropriate, since 1 full second in computer terms is a loong time. ...and I don't speak a lick of Portuguese. -- // Todd
Re: [PHP] time() TIMER in seconds or just numbers
On Mon, Mar 30, 2009 at 1:51 PM, Igor Escobar titiolin...@gmail.com wrote: Okey, but you understand the purpouse of it? On Mon, Mar 30, 2009 at 3:42 PM, haliphax halip...@gmail.com wrote: On Mon, Mar 30, 2009 at 11:37 AM, Igor Escobar titiolin...@gmail.com wrote: The people use that to measure performance. If you're intersted about that read http://www.igorescobar.com/blog/2009/03/05/benchmarking-de-desempenho-no-php/ (in portuguese, sorry) Regards, Igor Escobar On Mon, Mar 30, 2009 at 1:05 PM, haliphax halip...@gmail.com wrote: On Mon, Mar 30, 2009 at 10:47 AM, Richard Heyes rich...@php.net wrote: When someone does that, it means the execution time between $t1 and $t2... Is that for my benefit? Believe it or not, I do know the arcane art of subtraction... I would subtract more often, but sacrificial farm animals and black candles are so hard to come by these days... Oh, I'm fully aware of what it's for. FYI, microtime() is probably more appropriate, since 1 full second in computer terms is a loong time. ...and I don't speak a lick of Portuguese. Please stop top-posting. I'm fully aware of what it's for == I am aware of its purpose. My point was that time() gives you seconds since the UNIX epoch, whereas microtime(true) will give you more accurate results if you are looking to benchmark a script. If your script takes a few minutes and you don't really care about measuring those milli/micro seconds, then time() should suit your needs just fine. However, if your script can perform an iteration in less than one second, you have already eliminated the usefulness of time() for benchmarks. -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time() TIMER in seconds or just numbers
Andrew Williams wrote: what does time(); $t1 = time(); { do something } $t2 = time(); $end_time = $t2 - $t1; echo $end_time; what does $end_time represent? how do you determine the next 5 mins? So if you haven't deduced the answer from other replies, this would probably be more readable: $start_time = time(); //or microtime() //do something $end_time = time(); //or microtime() $duration = $end_time - $start_time; echo $duration; -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time() TIMER in seconds or just numbers
On Mon, Mar 30, 2009 at 3:35 PM, Shawn McKenzie nos...@mckenzies.net wrote: Andrew Williams wrote: what does time(); $t1 = time(); { do something } $t2 = time(); $end_time = $t2 - $t1; echo $end_time; what does $end_time represent? how do you determine the next 5 mins? So if you haven't deduced the answer from other replies, this would probably be more readable: $start_time = time(); //or microtime() //do something $end_time = time(); //or microtime() $duration = $end_time - $start_time; echo $duration; Don't forget--microtime() without the boolean true as an argument will split the result into two parts. Using true as the argument (minus quotes, of course) gives you a floating-point representation of seconds/milliseconds/etc. -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Time Wrong
Im pretty new with php, so this might be a pretty novice mistake, but the time displays wrong on two computers. ?php echo date('l F jS, o h i A');? Shows up 2 hours late...time on both computers is correct. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time Wrong
2009/1/21 Gary gwp...@ptd.net Im pretty new with php, so this might be a pretty novice mistake, but the time displays wrong on two computers. ?php echo date('l F jS, o h i A');? Shows up 2 hours late...time on both computers is correct. Thanks Do you mean on two computers visiting a php script? PHP is running on the server, so it will use server time -eddy
Re: [PHP] Time Wrong
Edmund Hertle wrote: 2009/1/21 Gary gwp...@ptd.net Im pretty new with php, so this might be a pretty novice mistake, but the time displays wrong on two computers. ?php echo date('l F jS, o h i A');? Shows up 2 hours late...time on both computers is correct. Thanks Do you mean on two computers visiting a php script? PHP is running on the server, so it will use server time -eddy makes sense.. check out http://php.net/date_default_timezone_set - probaly needs set -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time Wrong
Thanks for all the replies, I was able to set the time zone with one of the tutorials. Thanks again Gary Nathan Rixham nrix...@gmail.com wrote in message news:49779f04.4060...@gmail.com... Edmund Hertle wrote: 2009/1/21 Gary gwp...@ptd.net Im pretty new with php, so this might be a pretty novice mistake, but the time displays wrong on two computers. ?php echo date('l F jS, o h i A');? Shows up 2 hours late...time on both computers is correct. Thanks Do you mean on two computers visiting a php script? PHP is running on the server, so it will use server time -eddy makes sense.. check out http://php.net/date_default_timezone_set - probaly needs set -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Time zones and $_ENV vs getenv
Hello people. Argentina changed timezones (Oct 19th), just two weeks ago, and, as PHP has a separate table, I forgot to change the zones both in my machine and on the server. I did so yesterday, and have some problems. Here's what I did: 1) Downloaded the latest timezonedb (2008.9), compiled and installed it locally and on the server. Apparently no problem there. 2) I have a calendar on my pages (http://www.jcoppens.com/kayak/peperina/agenda.phpuniz=1) which shows the unix time stamp if the cursor is above a date (just to help debugging). The stamps coincide till Oct 19th, then differ by one hour (as compared to my PC). At the remote server, the time seems correct (-0200), on my machine it isn't (-0300). I _did_ restart my apache, and yes, the php.ini is correct. One strange thing I noticed (on both my machine and the server) is that $_ENV['TZ'] was empty, while getenv('TZ') was correctly set (America/Argentina/Cordoba). I'm confused... Can someone point me to some more tests I could do? Thanks, John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time Loop
MDB wrote: Hello All, I am trying to figure out how to loop through 2 given times. I have a start time and a end time and want to look through every X mins and add a radio button. Below is my latest try, can someone please help me out? $endTime = 17:00:00; $currentTime=09:00:00; $num_intervals = floor(($endTime - $currentTime) / 30); echo (Num_INter: .$num_intervals./br); $buffer_time = $currentTime; for($i = 0; $i $num_intervals; $i++) { echo (tr); echo (td.$currentTime./td); foreach ($days as $day) { echo (td); echo (input type='radio' name='dateTimeSelection' value=$day); echo (/td); } $buffer_time += $interval; echo (/tr); } ps I was having problems with my news reader, this may be posted twice, if so. Sorry. TIA Here is what I think you are looking for. ?php # I am guessing that your $days array looks something like this. $days = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); # Get todays information $d = getdate(); $endTime = 17:00:00; list($et_hr, $et_min, $et_sec) = explode(':', $endTime); $unix_endTime = mktime($et_hr, $et_min, $et_sec, $d['mon'], $d['mday'], $d['year']); $currentTime=09:00:00; list($ct_hr, $ct_min, $ct_sec) = explode(':', $currentTime); $unix_currentTime = mktime($ct_hr, $ct_min, $ct_sec, $d['mon'], $d['mday'], $d['year']); $interval = 60; # Calculate how many rows their should be $num_intervals = floor(($unix_endTime - $unix_currentTime) / $interval); echo 'Num_INter: ', $num_intervals, '/br'; echo 'formtable'; for ( $i=$unix_currentTime; $i = $unix_endTime; $i=($i+$interval) ) { echo 'tr', 'td', date('Y/m/d H:i:s', $i), '/td'; foreach ($days AS $day) { echo 'td', 'input type=radio name=dateTimeSelection value=', $day, ' /', $day, '/td'; } # Don't forget to reset the $days array # otherwise the array pointer is at the last index reset($days); echo '/tr'; } echo '/table/form'; ? -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time Loop
Thank you, I will try that out. Robert Cummings [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Mon, 2008-09-29 at 17:01 -0400, MDB wrote: Hello All, I am trying to figure out how to loop through 2 given times. I have a start time and a end time and want to look through every X mins and add a radio button. Below is my latest try, can someone please help me out? $endTime = 17:00:00; $currentTime=09:00:00; $num_intervals = floor(($endTime - $currentTime) / 30); You should convert your times to minutes so you can use minute intervals... the following was written directly into the email and so it is UNTESTED: ?php $bits = explode( ':', $currentTime ); $currentTime = $bits[0] * 60 + $bits[1]; $bits = explode( ':', $endTime ); $endTime = $bits[0] * 60 + $bits[1]; $interval = 15; // minutes for( $i = $currentTime; $i = $endTime; $i += $interval ) { $time = floor( $i / 60 ).':'.($i % 60).':00'; } ? Adapt to fit your needs. Note: I used a time interval like you state in your above description (X mins). But the code you submitted used appeared to use number of time slices instead. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Time Loop
Hello All, I am trying to figure out how to loop through 2 given times. I have a start time and a end time and want to look through every X mins and add a radio button. Below is my latest try, can someone please help me out? $endTime = 17:00:00; $currentTime=09:00:00; $num_intervals = floor(($endTime - $currentTime) / 30); echo (Num_INter: .$num_intervals./br); $buffer_time = $currentTime; for($i = 0; $i $num_intervals; $i++) { echo (tr); echo (td.$currentTime./td); foreach ($days as $day) { echo (td); echo (input type='radio' name='dateTimeSelection' value=$day); echo (/td); } $buffer_time += $interval; echo (/tr); } ps I was having problems with my news reader, this may be posted twice, if so. Sorry. TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time Loop
On Mon, 2008-09-29 at 17:01 -0400, MDB wrote: Hello All, I am trying to figure out how to loop through 2 given times. I have a start time and a end time and want to look through every X mins and add a radio button. Below is my latest try, can someone please help me out? $endTime = 17:00:00; $currentTime=09:00:00; $num_intervals = floor(($endTime - $currentTime) / 30); You should convert your times to minutes so you can use minute intervals... the following was written directly into the email and so it is UNTESTED: ?php $bits = explode( ':', $currentTime ); $currentTime = $bits[0] * 60 + $bits[1]; $bits = explode( ':', $endTime ); $endTime = $bits[0] * 60 + $bits[1]; $interval = 15; // minutes for( $i = $currentTime; $i = $endTime; $i += $interval ) { $time = floor( $i / 60 ).':'.($i % 60).':00'; } ? Adapt to fit your needs. Note: I used a time interval like you state in your above description (X mins). But the code you submitted used appeared to use number of time slices instead. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP time out for socket_recvfrom or socket_read block call
Hi, How can use time out mechanism in PHP when calling socket_recvfrom or socket_read (in block service)? I know the non-block system call can be used, but I need to use a block system call, the block socket_recvfrom or socket_read should be either returned to be failed, or canceled when a time out is occurred. Thank you. Kind Regards, Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time formatting issues
The date_format function of MySQL should work for time as well... What are the errors? What did you use for the time format? On Sat, July 14, 2007 8:27 am, Melissa wrote: I have a DB with a field type DATE (called TideDATE) and a field type TIME (one of which is called highFIRST) How can I format the time fields from displaying 00:00:00 (a 24 hour clock) to HH:MM am/pm format? The DATE function has all kinds of neat formatters, but I do not find any for TIME In DATE, I would say g:i A If I try it with a TIME field, I get errors! I HAVE NEVER USED A NEWSGROUP BEFORE, SO I HOPE I HAVE DONE THIS CORRECTLY... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time formatting issues
Melissa wrote: I have a DB with a field type DATE (called TideDATE) and a field type TIME (one of which is called highFIRST) How can I format the time fields from displaying 00:00:00 (a 24 hour clock) to HH:MM am/pm format? $time = '13:05:00'; list($hr, $min, $sec) = explode(':', $time); if ($hr 12) { $new_time = ($hr - 12); $ampm = 'pm'; } elseif ($hr == 12) { $new_time = '12'; $ampm = 'pm'; } else { $new_time = $hr; $ampm = 'am'; } $new_time .= ':' . $min . ':' . $sec . ' ' . $ampm; pretty simple ;) (I'm sure someone will find a way to make this better but that should work :P). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time formatting issues
Melissa wrote: I have a DB with a field type DATE (called TideDATE) and a field type TIME (one of which is called highFIRST) How can I format the time fields from displaying 00:00:00 (a 24 hour clock) to HH:MM am/pm format? The DATE function has all kinds of neat formatters, but I do not find any for TIME In DATE, I would say g:i A If I try it with a TIME field, I get errors! I HAVE NEVER USED A NEWSGROUP BEFORE, SO I HOPE I HAVE DONE THIS CORRECTLY... What type of database are you using? You can probably do this right in the database. If MySQL you can do the following: select DATE_FORMAT(time_column, '%h:%i:%s %p') from your_table; Tests: mysql select DATE_FORMAT('2007-07-16 14:19:00', '%h:%i:%s %p'); +---+ | DATE_FORMAT('2007-07-16 14:19:00', '%h:%i:%s %p') | +---+ | 02:19:00 PM | +---+ 1 row in set (0.00 sec) mysql select DATE_FORMAT('2007-07-16 04:19:00', '%h:%i:%s %p'); +---+ | DATE_FORMAT('2007-07-16 04:19:00', '%h:%i:%s %p') | +---+ | 04:19:00 AM | +---+ 1 row in set (0.00 sec) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Time formatting issues
Thank you VERY much Jay, Chris and Gary! I tried the php code to change it and that worked Great, as Chris suggested I am about to see how it flies with changing the SQL DB directly as Gary suggested. I might even just ADD a new DB field for the new format... The mktime function looks VERY interesting, but confusing to a newbie... That will be next on my list of things to try. Melissa -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time formatting issues
Melissa W. Dickens wrote: Thank you VERY much Jay, Chris and Gary! I tried the php code to change it and that worked Great, as Chris suggested I am about to see how it flies with changing the SQL DB directly as Gary suggested. I might even just ADD a new DB field for the new format... The mktime function looks VERY interesting, but confusing to a newbie... That will be next on my list of things to try. Melissa No need to create a new field just for another format. If you are using mysql 5 you can create a view. mysql create view view_name as select DATE_FORMAT(time_column, '%h:%i:%s %p') as time from your_table; Query OK, 0 rows affected (0.00 sec) mysql select * from view_name; +-+ | time| +-+ | 12:45:41 PM | +-+ 1 row in set (0.00 sec) This way you're not updating multiple columns with the same data formated differently. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Time formatting issues
Melissa W. Dickens [EMAIL PROTECTED] 770-667-8933 843-838-7388 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, July 16, 2007 12:50 PM To: Melissa W. Dickens Hmm... Another reason to upgrade! We are running version 4 something or other! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Time formatting issues
I have a DB with a field type DATE (called TideDATE) and a field type TIME (one of which is called highFIRST) How can I format the time fields from displaying 00:00:00 (a 24 hour clock) to HH:MM am/pm format? The DATE function has all kinds of neat formatters, but I do not find any for TIME In DATE, I would say g:i A If I try it with a TIME field, I get errors! I HAVE NEVER USED A NEWSGROUP BEFORE, SO I HOPE I HAVE DONE THIS CORRECTLY... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Time formatting issues
[snip] I have a DB with a field type DATE (called TideDATE) and a field type TIME (one of which is called highFIRST) How can I format the time fields from displaying 00:00:00 (a 24 hour clock) to HH:MM am/pm format? [/snip] Have a look at http://www.php.net/mktime -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Time formatting issues
Thank you, Jay, that is interesting. I am looking for the am / pm denomination, which I do not see in mktime() I am essentially trying to have the TIME type which is a 24 hour clock display instead as a 12 hour clock with am and pm. I AM A TOTAL NEWBIE, (2ND DAY ever) so if I misunderstood the answer, I am sorry! Melissa -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time or date picker ?
At 8:11 PM +0100 3/19/07, Alain Roger wrote: Hi, I've already seen some webpages which include a time or date picker (like a calendar) written in PHP and on which user could type the year and after, select the month and date (using month). I'm looking for something like that. Where can i find one for free ? thanks -- Alain Alain: You can choose -- php, flash, or javascript. http://xn--nvg.com/calendar Let me know which one you want. tedd ps: If you can't read the above url, get opera. -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] time or date picker ?
Hi, I've already seen some webpages which include a time or date picker (like a calendar) written in PHP and on which user could type the year and after, select the month and date (using month). I'm looking for something like that. Where can i find one for free ? thanks -- Alain Windows XP SP2 PostgreSQL 8.1.4 Apache 2.0.58 PHP 5
Re: [PHP] time or date picker ?
On 3/19/07, Alain Roger [EMAIL PROTECTED] wrote: Hi, I've already seen some webpages which include a time or date picker (like a calendar) written in PHP and on which user could type the year and after, select the month and date (using month). I'm looking for something like that. Where can i find one for free ? thanks -- Alain This is client side PHP is server side... Go to the javascript list. Tijnema Windows XP SP2 PostgreSQL 8.1.4 Apache 2.0.58 PHP 5 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time or date picker ?
On Mon, March 19, 2007 2:11 pm, Alain Roger wrote: I've already seen some webpages which include a time or date picker (like a calendar) written in PHP and on which user could type the year and after, select the month and date (using month). I'm looking for something like that. Where can i find one for free ? Actually, you haven't seen that. You thought you saw that, because the URL ended in .php But what you really saw was some JavaScript. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] time
On Mon, January 29, 2007 10:55 pm, Jay Blanchard wrote: [snip] I am writing a program for managing leads and contacts. I would like to add the ability to see what TIME it is where the contact is not there server time. So if you looked at a list of contacts from all over the country you would see different times compared to what time it is where the user is at. What should I be looking at to calculate out the different time zones. Could somebody just point me in the write direction at this time I have no idea on how to proceeded. [/snip] You would use JavaScript to capture their local 'browser' time and process it with PHP Since their computer clock is probably wrong (way wrong) this may be very problematic... Assuming contacts know what time zone they (usually) live in, you can ask them to set that in their profile. You can even pre-populate it with your best guess from their IP and one of the zillion IP to country databases floating around. Ultimately, however, you're going to have problems because there's no way you can know for sure for sure where the user is, even if they are usually in time zone X. It's amazing just how complicated time can be, when you start actually trying to do anything useful with it. Puns intended. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time
Richard Kurth wrote: [snip] I am writing a program for managing leads and contacts. I would like to add the ability to see what TIME it is where the contact is not there server time. So if you looked at a list of contacts from all over the country you would see different times compared to what time it is where the user is at. What should I be looking at to calculate out the different time zones. Could somebody just point me in the write direction at this time I have no idea on how to proceeded. [/snip] You would use JavaScript to capture their local 'browser' time and process it with PHP I am not looking for something where I am on line with these people some do not have internet access. I would be calling them on the phone. I need a way to get the time at there location using what info I already have like the address zip code and phone number. It would probably have to be compared to a database of some sort or the time zone file on a lynx server. You are going to need the info found at www.melissadata.com Something like a LERG database/cross reference Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] time
If you have the timezone offset stored for each contact, you can compare that to the timezone offset of the server and do the math on a timestamp value. // return value format: hhmm // -0500 for US/EST, -5 hours relative to GMT $timeZoneOfServer = date(O); -Original Message- From: Richard Kurth [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 30, 2007 12:12 AM To: php-general@lists.php.net Subject: RE: [PHP] time [snip] I am writing a program for managing leads and contacts. I would like to add the ability to see what TIME it is where the contact is not there server time. So if you looked at a list of contacts from all over the country you would see different times compared to what time it is where the user is at. What should I be looking at to calculate out the different time zones. Could somebody just point me in the write direction at this time I have no idea on how to proceeded. [/snip] You would use JavaScript to capture their local 'browser' time and process it with PHP I am not looking for something where I am on line with these people some do not have internet access. I would be calling them on the phone. I need a way to get the time at there location using what info I already have like the address zip code and phone number. It would probably have to be compared to a database of some sort or the time zone file on a lynx server. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] time
[snip] I am writing a program for managing leads and contacts. I would like to add the ability to see what TIME it is where the contact is not there server time. So if you looked at a list of contacts from all over the country you would see different times compared to what time it is where the user is at. What should I be looking at to calculate out the different time zones. Could somebody just point me in the write direction at this time I have no idea on how to proceeded. You would use JavaScript to capture their local 'browser' time and process it with PHP I am not looking for something where I am on line with these people some do not have internet access. I would be calling them on the phone. I need a way to get the time at there location using what info I already have like the address zip code and phone number. It would probably have to be compared to a database of some sort or the time zone file on a lynx server. [/snip] Aha, that was not what your original post asked. Search for time-zone databases on Google. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] time
[snip] I am writing a program for managing leads and contacts. I would like to add the ability to see what TIME it is where the contact is not there server time. [/snip] I have implemented this feature in our home-grown CRM system. I used the list of timezones on Wikipedia as a starting point and store the UTC offset for each contact (selected from a drop down). When displaying their info, I use this offset to calculate their local time from my server time. BTW, you'll need to use a float since there are some non-integer timezone differences. Edward -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time
# [EMAIL PROTECTED] / 2007-01-30 16:52:02 -: BTW, you'll need to use a float since there are some non-integer timezone differences. No need to lose information. Just store the offset in minutes, problem solved. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] time
[snip] I am writing a program for managing leads and contacts. I would like to add the ability to see what TIME it is where the contact is not there server time. So if you looked at a list of contacts from all over the country you would see different times compared to what time it is where the user is at. What should I be looking at to calculate out the different time zones. Could somebody just point me in the write direction at this time I have no idea on how to proceeded. [/snip] You would use JavaScript to capture their local 'browser' time and process it with PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time
test Jay Blanchard : [snip] I am writing a program for managing leads and contacts. I would like to add the ability to see what TIME it is where the contact is not there server time. So if you looked at a list of contacts from all over the country you would see different times compared to what time it is where the user is at. What should I be looking at to calculate out the different time zones. Could somebody just point me in the write direction at this time I have no idea on how to proceeded. [/snip] You would use JavaScript to capture their local 'browser' time and process it with PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] time
[snip] I am writing a program for managing leads and contacts. I would like to add the ability to see what TIME it is where the contact is not there server time. So if you looked at a list of contacts from all over the country you would see different times compared to what time it is where the user is at. What should I be looking at to calculate out the different time zones. Could somebody just point me in the write direction at this time I have no idea on how to proceeded. [/snip] You would use JavaScript to capture their local 'browser' time and process it with PHP I am not looking for something where I am on line with these people some do not have internet access. I would be calling them on the phone. I need a way to get the time at there location using what info I already have like the address zip code and phone number. It would probably have to be compared to a database of some sort or the time zone file on a lynx server. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time-Zone juggling
On 11/8/06, Travis Doherty [EMAIL PROTECTED] wrote: David Giragosian wrote: Does Daylight Savings alter Zulu time? (I'm guessing yes). How did the military deal with that? I use a date-time field as a primary key in db tables that get an insert a minute. I had to jump through a number of hoops to turn off DST on the (RH Linux) server. David UTC (or GMT, or Zulu, or Z) does not observe Daylight Savings Time. In any database that you store timestamps and need to know exactly what that timestamp means you should use UTC, then use application logic to translate to the users time zone. Another option would be to store epoch time (seconds since the OS's epoch) and work the same result from that, I prefer storing human-readable timestamps even if you have to do the datemath in your head to read them in your own timezone. Epoch does not count leap-seconds like UTC so it can be off by a tiny bit at any given time. Epoch time also differs on different operating systems - Unix is 1970-01-01 at 00:00:00 UTC, Windows seems to use 1601-01-01 at 00:00:00 UTC... I don't know if that would ever matter though - I imagine the database server would mask this and the application would port to windows without problems (no idea.) UTC has no DST from: http://en.wikipedia.org/wiki/Time_zone Due to daylight saving time, UTC is local time at the Royal Observatory, Greenwich http://en.wikipedia.org/wiki/Royal_Observatory%2C_Greenwich only between 01:00 UTC on the last Sunday in October and 01:00 UTC on the last Sunday in March. For the rest of the year, local time there is UTC+1 http://en.wikipedia.org/wiki/UTC%2B1, known in the United Kingdom http://en.wikipedia.org/wiki/United_Kingdom as British Summer Time http://en.wikipedia.org/wiki/British_Summer_Time (BST). Similar circumstances apply in many places. ** Travis Doherty TixTime We are using now() in the MySQL db to insert current time. Database version is 4.0.24. I see that in 4.1.* there is utc_timestamp(). Anybody know if this function avoids DST? Might be worth the hassle of upgrade and possible code changes in the PHP scripts to obtain this feature. Shudder Thanks, David
Re: [PHP] Time-Zone juggling
David Giragosian wrote: On 11/8/06, Travis Doherty [EMAIL PROTECTED] wrote: David Giragosian wrote: Does Daylight Savings alter Zulu time? (I'm guessing yes). How did the military deal with that? I use a date-time field as a primary key in db tables that get an insert a minute. I had to jump through a number of hoops to turn off DST on the (RH Linux) server. David UTC (or GMT, or Zulu, or Z) does not observe Daylight Savings Time. In any database that you store timestamps and need to know exactly what that timestamp means you should use UTC, then use application logic to translate to the users time zone. Another option would be to store epoch time (seconds since the OS's epoch) and work the same result from that, I prefer storing human-readable timestamps even if you have to do the datemath in your head to read them in your own timezone. Epoch does not count leap-seconds like UTC so it can be off by a tiny bit at any given time. Epoch time also differs on different operating systems - Unix is 1970-01-01 at 00:00:00 UTC, Windows seems to use 1601-01-01 at 00:00:00 UTC... I don't know if that would ever matter though - I imagine the database server would mask this and the application would port to windows without problems (no idea.) UTC has no DST from: http://en.wikipedia.org/wiki/Time_zone Due to daylight saving time, UTC is local time at the Royal Observatory, Greenwich http://en.wikipedia.org/wiki/Royal_Observatory%2C_Greenwich only between 01:00 UTC on the last Sunday in October and 01:00 UTC on the last Sunday in March. For the rest of the year, local time there is UTC+1 http://en.wikipedia.org/wiki/UTC%2B1, known in the United Kingdom http://en.wikipedia.org/wiki/United_Kingdom as British Summer Time http://en.wikipedia.org/wiki/British_Summer_Time (BST). Similar circumstances apply in many places. ** Travis Doherty TixTime We are using now() in the MySQL db to insert current time. Database version is 4.0.24. I see that in 4.1.* there is utc_timestamp(). Anybody know if this function avoids DST? Might be worth the hassle of upgrade and possible code changes in the PHP scripts to obtain this feature. Shudder Thanks, David you don't quite understand what UTC is, do you :) UTC doesn't have DST. It just doesn't, at all. If it returns a timestamp in UTC offset, it will avoid DST for you... - tul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time-Zone juggling
On 11/9/06, M.Sokolewicz [EMAIL PROTECTED] wrote: David Giragosian wrote: On 11/8/06, Travis Doherty [EMAIL PROTECTED] wrote: David Giragosian wrote: Does Daylight Savings alter Zulu time? (I'm guessing yes). How did the military deal with that? I use a date-time field as a primary key in db tables that get an insert a minute. I had to jump through a number of hoops to turn off DST on the (RH Linux) server. David UTC (or GMT, or Zulu, or Z) does not observe Daylight Savings Time. In any database that you store timestamps and need to know exactly what that timestamp means you should use UTC, then use application logic to translate to the users time zone. Another option would be to store epoch time (seconds since the OS's epoch) and work the same result from that, I prefer storing human-readable timestamps even if you have to do the datemath in your head to read them in your own timezone. Epoch does not count leap-seconds like UTC so it can be off by a tiny bit at any given time. Epoch time also differs on different operating systems - Unix is 1970-01-01 at 00:00:00 UTC, Windows seems to use 1601-01-01 at 00:00:00 UTC... I don't know if that would ever matter though - I imagine the database server would mask this and the application would port to windows without problems (no idea.) UTC has no DST from: http://en.wikipedia.org/wiki/Time_zone Due to daylight saving time, UTC is local time at the Royal Observatory, Greenwich http://en.wikipedia.org/wiki/Royal_Observatory%2C_Greenwich only between 01:00 UTC on the last Sunday in October and 01:00 UTC on the last Sunday in March. For the rest of the year, local time there is UTC+1 http://en.wikipedia.org/wiki/UTC%2B1, known in the United Kingdom http://en.wikipedia.org/wiki/United_Kingdom as British Summer Time http://en.wikipedia.org/wiki/British_Summer_Time (BST). Similar circumstances apply in many places. ** Travis Doherty TixTime We are using now() in the MySQL db to insert current time. Database version is 4.0.24. I see that in 4.1.* there is utc_timestamp(). Anybody know if this function avoids DST? Might be worth the hassle of upgrade and possible code changes in the PHP scripts to obtain this feature. Shudder Thanks, David you don't quite understand what UTC is, do you :) UTC doesn't have DST. It just doesn't, at all. If it returns a timestamp in UTC offset, it will avoid DST for you... - tul We use now() to do timestamp inserts in the MySQL db. now() in MySQL is based upon the OS time, which is obviously affected by timezone setting as an offset from UTC. When I've set the RH server to use UTC, the OS time was still affected by the rule which altered UTC to the timezone setting (I'm in the process of moving my office or else I'd be able to find the document describing how to alter the RH OS to not obey DST changes). My question is based upon this experience. If select utc_timestamp() in MySQL truly returns the UTC with timezone offset and without any adjustments for DST, that would be just peachy. Thanks, David
Re: [PHP] Time-Zone juggling
At 12:48 AM -0500 11/8/06, Travis Doherty wrote: This can be a big problem to some apps, and others might be fine with the workaround like we've done where you loose a tiny bit of data (It's 08:00 on the day after the timechange, is this ticket from 01:30:00 6.5 or 7.5 hours old? who cares.. just reply.) and At 9:53 PM -0600 11/7/06, Richard Lynch wrote: This time zone stuff always gets me head all spun around, I admit freely. You're not alone. What about just using what we did in the service, namely Zulu? http://www.grc.nasa.gov/WWW/MAEL/ag/zulu.htm At least that points to a common datum for all time related issues. I just wonder how they came up with the acronym of UTC for Coordinated Universal Time? Best, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time-Zone juggling
On 11/8/06, tedd [EMAIL PROTECTED] wrote: At 12:48 AM -0500 11/8/06, Travis Doherty wrote: This can be a big problem to some apps, and others might be fine with the workaround like we've done where you loose a tiny bit of data (It's 08:00 on the day after the timechange, is this ticket from 01:30:00 6.5 or 7.5 hours old? who cares.. just reply.) and At 9:53 PM -0600 11/7/06, Richard Lynch wrote: This time zone stuff always gets me head all spun around, I admit freely. You're not alone. What about just using what we did in the service, namely Zulu? http://www.grc.nasa.gov/WWW/MAEL/ag/zulu.htm At least that points to a common datum for all time related issues. I just wonder how they came up with the acronym of UTC for Coordinated Universal Time? Best, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php tedd, Does Daylight Savings alter Zulu time? (I'm guessing yes). How did the military deal with that? I use a date-time field as a primary key in db tables that get an insert a minute. I had to jump through a number of hoops to turn off DST on the (RH Linux) server. David
Re: [PHP] Time-Zone juggling
At 9:01 AM -0600 11/8/06, David Giragosian wrote: tedd, Does Daylight Savings alter Zulu time? (I'm guessing yes). How did the military deal with that? LOL -- do you think that the military gives a hoot about daylight savings time? That's one of those civilian things. In military time, Oh Dark Thirty, is $#%# early regardless of what civilians do. :-) I use a date-time field as a primary key in db tables that get an insert a minute. I had to jump through a number of hoops to turn off DST on the (RH Linux) server. If it was critical to have a absolute date/time stamp, such as in a patient's registration on an organ transplant list, then I would hope that the people in charge would work with an absolute time and not one subject to DST or even subject to which time zone the patient is located. Sometimes even seconds count for selecting which patient is entitled to the transplant. If they don't use an absolute time, then it would be better for a patient to register for a transplant on the west coast (or even further west) than the east coast, and that doesn't sound right, does it? But, I don't specifically know what method they use. Any idea? tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time-Zone juggling
David Giragosian wrote: Does Daylight Savings alter Zulu time? (I'm guessing yes). How did the military deal with that? I use a date-time field as a primary key in db tables that get an insert a minute. I had to jump through a number of hoops to turn off DST on the (RH Linux) server. David UTC (or GMT, or Zulu, or Z) does not observe Daylight Savings Time. In any database that you store timestamps and need to know exactly what that timestamp means you should use UTC, then use application logic to translate to the users time zone. Another option would be to store epoch time (seconds since the OS's epoch) and work the same result from that, I prefer storing human-readable timestamps even if you have to do the datemath in your head to read them in your own timezone. Epoch does not count leap-seconds like UTC so it can be off by a tiny bit at any given time. Epoch time also differs on different operating systems - Unix is 1970-01-01 at 00:00:00 UTC, Windows seems to use 1601-01-01 at 00:00:00 UTC... I don't know if that would ever matter though - I imagine the database server would mask this and the application would port to windows without problems (no idea.) UTC has no DST from: http://en.wikipedia.org/wiki/Time_zone Due to daylight saving time, UTC is local time at the Royal Observatory, Greenwich http://en.wikipedia.org/wiki/Royal_Observatory%2C_Greenwich only between 01:00 UTC on the last Sunday in October and 01:00 UTC on the last Sunday in March. For the rest of the year, local time there is UTC+1 http://en.wikipedia.org/wiki/UTC%2B1, known in the United Kingdom http://en.wikipedia.org/wiki/United_Kingdom as British Summer Time http://en.wikipedia.org/wiki/British_Summer_Time (BST). Similar circumstances apply in many places. ** Travis Doherty TixTime -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Time-Zone juggling
I have a PostgreSQL database chockful of datatype: time without time zone The times I chucked in there are, like, '7:00 PM' and they all seem fine... Until I start trying to generate an RFC 882 datetime stamp. :-( At that point, the fact that the server lives in Portland OR, and my times are all based in Chicago means that my output is: Mon, 03 Apr 2006 17:00:00 PDT even though the actual date/time in question is REALLY at 20:00 in Chicago. I'm just doing the naive: select whatdate, whattime from ... list($y, $m, $d) = explode('-', $whatdate); list($h, $i, $s) = explode(':', $whattime); $datetime_882 = date(DATE_RFC882, mktime($h, $i, $s, $m, $d, $y)); This is PHP4, and I've done an if(!defined()) define() to get the DATE_RFC882 constant. What is the least-stupid way to fix this, and get 20:00 in the Portland OR server to turn into: Mon, 03 Apr 2006 20:00:00 CDT which is what time it really was. E. Without changing the schema which means having to re-do everything else in the application. That's probably the RIGHT way to fix it, but that ain't happening. I've been dinking with gmmktime() and reading about setlocale() but none of them seem to be the Right Answer. I got a couple stupid ways I think I could fix it, and I'd rather not do those, cuz they're stupid. :-) E.g., str_replace(array('PDT', 'PST'), array('CDT', 'CST'), $datetime); This time zone stuff always gets me head all spun around, I admit freely. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Time-Zone juggling
Richard Lynch wrote: What is the least-stupid way to fix this, and get 20:00 in the Portland OR server to turn into: Mon, 03 Apr 2006 20:00:00 CDT which is what time it really was. E. Without changing the schema which means having to re-do everything else in the application. That's probably the RIGHT way to fix it, but that ain't happening. Yeah... I ran into the same stuff a few weeks ago with the DST change. The quickest solution that is *almost* OK is using putenv(tz=america/montreal) or putenv(tz=america/san_diego) etc.. (should really be the date_default_timezone_get/set functions) Datetime fields do not have timezone stored (mysql too.) The only real solution to this problem is to always store datetimes in GMT/UTC. That is the correct thing to do, and until that is done our workaround still has one problem (that isn't big enough to warrant reworking the ticketing code that inserts to the db...) The remaining problem is that until we store in UTC we will never know which 01:30:00 a timestamp refers to, EDT or EST (Eastern Daylight, or Eastern Standard.) In UTC this doesn't happen. Of course there is no problem for spring, only in the fall time change. This can be a big problem to some apps, and others might be fine with the workaround like we've done where you loose a tiny bit of data (It's 08:00 on the day after the timechange, is this ticket from 01:30:00 6.5 or 7.5 hours old? who cares.. just reply.) Travis Doherty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php