Sunday, March 22, 2015

Re: datetime and timezone best practice?

Hello,

I would do something like this.

1. Make sure a timezone string is saved with the user's profile. Once user logs in, the timezone string can now be retrieved using the Auth component ($this->Auth->user('timezone')).
2. Let the user enter the date you need, hopefully in a usable format.
3. Use CakeTime::toServer($dateString, $timezone) to convert the user's input back to UTC (which you already set your server's time to). $dateString should be your user's input (strtotime parseable), and $timezone should be the timezone string saved with your user's profile (see #1).
4. ...
5. Profit.

HTH.
OJ

On Friday, March 20, 2015 at 4:29:08 PM UTC+8, Andreas Witte wrote:
Hello everbody,

I would kindly like to attract your attention to a question I wrote on stackoverflow yesterday.

Has anyone any best practice tutorial or any advice how to solve it?

Thanks in advance and kind regards,
Andreas

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: