Jump to content

Charlie.

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

About Charlie.

  • Birthday 04/19/1985

Contact Methods

  • Website URL
    http://blue-wildebeest.blogspot.com
  • ICQ
    340777280
  • Yahoo
    scmartindale

Profile Information

  • Gender
    Not Telling
  • Location
    Port Elizabeth, South Africa

Charlie.'s Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Consider the following: I have a PHP script on the server that generates an HTML form. It wraps it in XML, like so: <xhtml> <form... ... </form> ... </xhtml> This is done because, strictly speaking, XML documents should only have one root node and my application's design states that this script will return well-formed XML. There may be more than just a form element in the response. I have a javascript function that uses Ajax to GET this. The code that fetches it is nothing special. Once it returns, I have a response object with two properties: responseText and responseXML. Looking at responseText shows that the Ajax code works perfectly and does get the correct XML back. Using getElementsByTagName('xhtml'), I can get the xhtml element successfully. Now, I want to insert ALL the HTML within that element into a conveniently prepared DIV element on my page. How do I do this? I know that IE would allow me to set the "innerHTML" property of my DIV to the "xml" property of my xhtml node, but the "xml" property is not supported by other browsers, so that does not help. (My reference browser is Firefox, BTW) Please help!
  2. Heh, sounds easy. LOL. Grunt.. Your right about the lack of documentation. Are UTC and GMT unaffected by DST? If so, then what you propose will work and so will the code that I have written so far. Thanks.
  3. I wrote a custom date handler that managed to successfully perform a roundtrip to MySql and back. For a unit test, I started with time() and added about three hours for each itteration. (This cycled through dates round the whole year, there were 2000 itterations) My date wrapper would hold, as a private member, a UNIX timestamp. It had functions to get this out as a local time or a GMT time. For each itteration, I called the local time fuction, storing the result, called the GMT time function, storing the result. I then created a new instance of the wrapper and told it to parse the GMT string (effectively what would come out of MySql) and then compared the local time string to that of the original. All 2000 itterations succeeded. I converted my UNIX timestamp to a MySql GMT format with: $dateString = gmdate("Y-m-d H:i:s", $this->_dateTime); I converted back with: strtotime($dateString . " GMT") The local time string values I checked came out of: date(DATE_W3C, $this->_dateTime); My unit test worked and, because I was storing it in the database as a DATETIME value, the round trip to MySql worked. When I printed the local time strings to the screen, to check that my itteration had actually tested the whole year round, I noticed an interesting anomaly: for some of the year it said that the two matching dates where in GMT +3, not +2. My location does not use DST, so I was very confused - resulting in this thread. Could this be a configuration issue in my PHP config file? Are my methods close enough to best practices to be reliable in a mission critical application? Any suggestions on how I would convert $this->_dateTime (the private member that I use to store my unix timestamp) to a string that represents that time in any timezone? (Assume that I know the timezone from a setting in the user's profile) I always assumed that I would have to store two settings in the user's profile: their timezone and whether times should be automatically adjusted for DST. I assumed that it is impossible to reliably determine the timezone from which an HTTP request originated.
  4. Can someone please explain the theory of dates, timestamps, zones, DST, MySql and PHP to me, or point me in the direction of a really good article. I have searched the web and both PHP and MySql docs, but I cannot find a clear, concise article that describes the best practices when handling dates and times. I am writing an application that may be used in many time zones. I am in GMT+2 (South Africa) which does not use DST. Living in a non-DST country, I am not sure of how DST works, exactly. I only understand why it was implemented. I want to know what the best practices would be for storing dates in MySql and being able to input them from and display them to a PHP user in any timezone - accurately. So far, I have managed to use the mysql UTC_TIMESTAMP() function to create records that have an acceptable representation of the current time. I use this to track session timeouts in my session state manager. Because I am only ever working with the difference between a value that was originally recorded with UTC_TIMESTAMP() and the current UTC_TIMESTAMP() value, there is no problem. I don't know what I will do when i have to capture a time entered by a user, who may be in any timezone. Please help, Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.