newbtophp Posted August 24, 2010 Share Posted August 24, 2010 Which is more reliable (functionality wise - not compatibility wise). Using Javascript (new Date(); function to detect user/visitor time automatically) or PHP's (Date and Time extension - DateTime:: - where the user/visitor selects their timezone themselfs) To retrieves the users/visitors time? Quote Link to comment Share on other sites More sharing options...
The Eagle Posted August 24, 2010 Share Posted August 24, 2010 I'd say PHP, some browsers may not have JavaScript (not a stronghold but just my example). echo date('l jS \of F Y h:i:s A'); Quote Link to comment Share on other sites More sharing options...
nethnet Posted August 24, 2010 Share Posted August 24, 2010 Depends if you are looking for convenience or extendability. Javascript will be convenient because it will automatically pull the users local time, which it seems like you want. PHP will require you to ask your users to select a timezone so you can manipulate the server time, or else it will just use the server time. So in this sense, I would say Javascript. But, PHP datetime will be easier to implement in a script if that is your ultimate goal, such as recording this time to a database (in which case you might consider using MySQL's now() function). I guess it just depends how you plan to use it. @The Eagle - any user who denies Javascript in this age just simply shouldn't be allowed to use the Internet at all. That would solve some issues, wouldn't it? Theo Quote Link to comment Share on other sites More sharing options...
The Eagle Posted August 24, 2010 Share Posted August 24, 2010 @newbtophp Yes, I agree, that's why I stated it wasn't a stronghold, but some people don't support JavaScript or enable it, I still think PHP is a better option to go with this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.