Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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