GMT seconds since epoch

This WebDNA talk-list message is from

2007


It keeps the original formatting.
numero = 68719
interpreted = N
texte = Hello, After the bulletin board thread, I was plunking around in my code, fixing various little things and re-familiarizing myself to it. I ran across a bug that I that I need help on. This code is the core of how this forum deals with time!... and the only cost of looking is to reply with some ideas on the bug! :-) [!] ** All times based on GMT ** [/!] [!] ** Each app install has server prefs. The prefs contain the server GMT offset. The code below formats the server offset into seconds ** [/!] [text]SERVER_OFFSET=[!] [/!][math]((([lookup db=....snip....&returnfield=F_GMT_ZONE]*60)*60)*-1)[/math][/text] [!] ** Set a GMT date and time stamp in the format of seconds since epoch, then add the pos. or neg. offset of the server ** [/!] [text]GMT_DTSTAMP=[!] [/!][math]((([math]{[date format=%m/%d/%Y]}[/math])-1)*86400)+([math]({[TIME format=%H:%M:%S]}+[SERVER_OFFSET])[/math])[/math][/text] [!] ** find the user GMT offset and format it as well into seconds since epoch ** [/!] [text]USER_OFFSET=[!] [/!][math](([USERGMT_OFFSET]*60)*60)[/math][/text] [!] ** Lastly, to test the current time, I have the code below, which is where I think the bug is ** [/!] [format seconds_to_time %I:%M %p][!] [/!][math][GMT_DTSTAMP]-((86400*[format .6d][math]([GMT_DTSTAMP]/86400)[/math][/format])+[USER_OFFSET])[/math][!] [/!][/format] The bug is this. I am exactly 12 hours behind. I can correct this by adding 43200 seconds (12 hours) to the code and get the right time. If I don't, my AM/PM is off: [!] ** Adding 12 hours ** [/!] [format seconds_to_time %I:%M %p][!] [/!][math]([GMT_DTSTAMP]-((86400*[format .6d][math]([GMT_DTSTAMP]/86400)[/math][/format])+[USER_OFFSET]))+43200[/math][!] [/!][/format] .... does anyone have an explanation why the code is 12 hours off? The server AM/PM is apparently set right. Donovan -- =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o DONOVAN D. BROOKE EUCA Design Center <- Web Development (specializing in eCommerce),-> <- Desktop Publishing, Print Consulting, Labels -> <-Glass Products, off-hand Classes/studio rental-> PH:> (608) 835-2476 | Forum:> http://egg.bz/forum/ Web Sites:> http://www.euca.us & http://www.egg.bz =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. GMT seconds since epoch ( Donovan Brooke 2007)
Hello, After the bulletin board thread, I was plunking around in my code, fixing various little things and re-familiarizing myself to it. I ran across a bug that I that I need help on. This code is the core of how this forum deals with time!... and the only cost of looking is to reply with some ideas on the bug! :-) [!] ** All times based on GMT ** [/!] [!] ** Each app install has server prefs. The prefs contain the server GMT offset. The code below formats the server offset into seconds ** [/!] [text]SERVER_OFFSET=[!] [/!][math]((([lookup db=....snip....&returnfield=F_GMT_ZONE]*60)*60)*-1)[/math][/text] [!] ** Set a GMT date and time stamp in the format of seconds since epoch, then add the pos. or neg. offset of the server ** [/!] [text]GMT_DTSTAMP=[!] [/!][math]((([math]{[date format=%m/%d/%Y]}[/math])-1)*86400)+([math]({[TIME format=%H:%M:%S]}+[SERVER_OFFSET])[/math])[/math][/text] [!] ** find the user GMT offset and format it as well into seconds since epoch ** [/!] [text]USER_OFFSET=[!] [/!][math](([USERGMT_OFFSET]*60)*60)[/math][/text] [!] ** Lastly, to test the current time, I have the code below, which is where I think the bug is ** [/!] [format seconds_to_time %I:%M %p][!] [/!][math][GMT_DTSTAMP]-((86400*[format .6d][math]([GMT_DTSTAMP]/86400)[/math][/format])+[USER_OFFSET])[/math][!] [/!][/format] The bug is this. I am exactly 12 hours behind. I can correct this by adding 43200 seconds (12 hours) to the code and get the right time. If I don't, my AM/PM is off: [!] ** Adding 12 hours ** [/!] [format seconds_to_time %I:%M %p][!] [/!][math]([GMT_DTSTAMP]-((86400*[format .6d][math]([GMT_DTSTAMP]/86400)[/math][/format])+[USER_OFFSET]))+43200[/math][!] [/!][/format] .... does anyone have an explanation why the code is 12 hours off? The server AM/PM is apparently set right. Donovan -- =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o DONOVAN D. BROOKE EUCA Design Center <- Web Development (specializing in eCommerce),-> <- Desktop Publishing, Print Consulting, Labels -> <-Glass Products, off-hand Classes/studio rental-> PH:> (608) 835-2476 | Forum:> http://egg.bz/forum/ Web Sites:> http://www.euca.us & http://www.egg.bz =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ Donovan Brooke

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

RE: [WebDNA] TCPConnect/cURL alternative for windows? (2010) Outsourcing partnership ... (2005) [LOOKUP] (1997) WebCatalog Use Question (1997) Cookies and WebCat?? (1999) Browser frames and URLs in the Location field (2004) Typhoon Rev. and PCS store problems (1999) Help needed! (SIMS recommendation) (1998) Using Cookie for client specific info? (1997) WebCat2b15MacPlugIn - [authenticate] not [protect] (1997) Download URL & access on the fly ? (1997) Upgrading old WebCat Database Files (1997) Trouble with Netscape (1998) [WebDNA] [BULK] Problem in Database "\x0B" (2011) Multiple security dbs (1997) And/or Search (1998) Help! WebCat2 bug (1997) HTML file size limit (1998) You sent this to me by mistake. (1998) Upgrading old WebCat Database Files (1997)