Re: Comparing Dates
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+unsubscr...@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.
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. http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::daysAsSql On 24 March 2014 10:32, José Lorenzo jose@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+unsubscr...@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+unsubscr...@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.
Comparing Dates
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+unsubscr...@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.
Comparing Dates
I want to compare 2 dates to make sure 1 date is older than the other. I believe I need to write my own comparison, but want to make sure there's nothing in Cake that already does this. I know date formats can be checked and I've seen a post saying the 'comparison' check is regex-based, which wouldn't help. Are my assumptions correct? Thanks, Paul --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Comparing Dates
still learning about cake... but surely converting the dates into a timestamp and doing the comparison is the best way? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Comparing Dates
I guess using strtotime will make it. If ever you use the $from- input for the date, do not forget to call the cleanupFields before the save, this will ensure your date is concatenated in your date field. On Aug 9, 6:11 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: still learning about cake... but surely converting the dates into a timestamp and doing the comparison is the best way? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---