Posts

Showing posts with the label Time

CakePHP Find Condition For A Query Between Two Dates

Answer : $conditions = array( 'conditions' => array( 'and' => array( array('Item.date_start <= ' => $date, 'Item.date_end >= ' => $date ), 'Item.title LIKE' => "%$title%", 'Item.status_id =' => '1' ))); Try the above code and ask if it not worked for you. Edit: As per @Aryan request, if we have to find users registered between 1 month: $start_date = '2013-05-26'; //should be in YYYY-MM-DD format $this->User->find('all', array('conditions' => array('User.reg_date BETWEEN '.$start_date.' AND DATE_ADD('.$start_date.', INTERVAL 30 DAY)'))); Here is CakePHP BETWEEN query example. I'm defining my arrays as variables, and then using those variables in my CakePHP find function call: // just return...

Conversion Of Nanoseconds To Milliseconds And Nanoseconds < 999999 In Java

Answer : Why not use the built in Java methods. The TimeUnit is part of the concurrent package so built exactly for you needs long durationInMs = TimeUnit.MILLISECONDS.convert(delayNS, TimeUnit.NANOSECONDS); For an ever shorter conversion using java.util.concurrent.TimeUnit , equivalent to what Shawn wrote above, you can use: long durationInMs = TimeUnit.NANOSECONDS.toMillis(delayNS); Just take the divmod of it with 1000000.

Allow Facebook Access Only In Specific Hours Of The Day With Squid

Answer : Taken from my configfile: # When is Facebook allowed? acl allowfacebooktime time MTWHF 12:15-13:45 # Facebook ACL acl facebookdotcom dstdomain .facebook.com # Only allow Facebook as described by allowfacebooktime http_access allow facebookdotcom allowfacebooktime # Else block facebook http_access deny facebookdotcom Squid supports time-base ACLS Something like this should work: acl FACEBOOK dst www.facebook.com acl LUNCH time MTWHF 12:30-1:30 http_access allow FACEBOOK LUNCH http_access deny FACEBOOK The "FACEBOOK" acl is probably wrong, I'm just making this up as I go :). The above says to allow access to whatever matches the FACEBOOK acl, during the time period matched by the LUNCH acl. It then says to deny access to the FACEBOOK acl as a fall back. Rules are matched in order, so the lunchtime rule has priority. Squid Wiki page on time ACLS