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:

Template not found error messages (1997) Multiple Newcarts (1996) Opinion: [input] should be called [output] ... (1997) WebCat2 - [format thousands] (1997) Nested tags count question (1997) Purchased cart being overwritten - still !?? (1997) New public beta available (1997) WebCat2 - [format thousands] (1997) WebCatalog 2.0 & WebDNA docs in HTML ... (1997) japanese characters (1997) Autoreturn Submit? (1997) Problems passing [SKU] with $Replace in 2.0 (1997) RAM variables (1997) What am I missing (1997) Snake Bites (1997) (2000) date search not working when type=date specified (2007) URL encoding -- still a problem (1998) Migrating to NT (1997) [WebDNA] Webserver does not respond occasionally (2018)