Monday, March 24, 2014

Re: Comparing Dates

I also use 'Y-m-d H:i:s' format, the Time helper makes it nice and easy to work with these fields anyhow, the former is more readable for an end user and also I don't think the benefits of switching it to numerical are worth the effort.





On 24 March 2014 10:32, José Lorenzo <jose.zap@gmail.com> wrote:
I use  '2014-03-01 23:25:03'


On Monday, March 24, 2014 5:26:17 AM UTC+1, advantage+ wrote:

When comparing dates as a value in the query it looks like this

`created` < '2014-03-01 23:25:03'

or

`created` >= '2014-02-23 23:25:03'

 

Is that the best way? '2014-03-01 23:25:03' does not look numical.

Or is it best to save that created value as strtotime() so you actually have a numerical value.

1393716303 since comparing if something is great / less than seems more appropriate.

 

I have tried both ways and each worked out exactly the same but just wondering which would be the best method and why?

 

Thanks,

Dave

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



--
Kind Regards
 Stephen Speakman

--
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: