A web developer's blog. PHP, MySQL, CakePHP, Zend Framework, Wordpress, Code Igniter, Django, Python, CSS, Javascript, jQuery, Knockout.js, and other web development topics.

Monthly Archives: January 2008

How to get the a date before current date in PHP

Given 2008-01-31 as the current date and the value of “$days_before” is 2, the code will echo 2008-01-29. The date 2 days before the current date. $days_before = 2; $current_date = date(’Y-m-d’); $str = strtotime($current_date)-(86400*$days_before); //1 day has 86400 echo … Continue reading

Posted in General | Tagged | Leave a comment

Get Difference Between 2 Dates Using PHP

Here is how you get the number of days between two dates.   function getdays($day1,$day2) { return round((strtotime($day2)-strtotime($day1))/(24*60*60),0); } $begin = date("Y-m-d"); // we set today as an example $end = "2007-01-29";   echo getdays($begin,$end).’ days’; This was taken from … Continue reading

Posted in General | Tagged | Leave a comment

A Very Quick Zend Framework VS. Code Igniter Comparison

Before anything else, I want the readers to know that I have used Zend Framework for a few months prior to using Code Igniter. I hang out in #zftalk (freenode) when I have time. So I am more of a … Continue reading

Posted in General | Tagged , | 15 Comments

Zend Framework Zend_Auth and a Plugin to Check Access to a Page

I have written this simple user authentication and user access privilege plugin in one of my Web Apps. First, in my AuthController, I have something like this: public function loginAction() { try { if ($this->_request->isPost()) { // collect the data … Continue reading

Posted in General | Tagged , | 9 Comments