Jump to content

Which is more reliable?


newbtophp

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/211645-which-is-more-reliable/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.