3
PHP: Change UTC time to local time
Did you know that you can quickly change UTC time stamps to Local time by doing the following:
//make sure your time is set
date_default_timezone_set('America/New_York');
$datetime = '2004-02-12T15:19:21+00:00';
//convert the given datetime string to time
$newDatetime = strtotime($datetime);
//re-contruct to format
$newDatetime = date('Y-m-d H:i:s', newDatetime);
It’s so obvious, but I only wished, I knew this before trying all sort of crazy stuff.
15
Unit Testing your AJAX requests with Zend Framework and PHPunit
I ran into a problem yesterday, when trying to create a couple of unit tests using PHPunit along side the Zend Framework.
If you want to unit test an action in a controller that checks the request to see if is an XML HTTP Request using the isXmlHttpRequest() method provided by the Zend Framework, then you will definitely run into a problem.
isXmlHttpRequest() pretty much checks to see if the $_SERVER['HTTP_X_REQUESTED_WITH'] is set with ‘XMLHttpRequest’, if not, then returns FALSE. I thought that by setting the server variable with XMLHttpRequest directly will allow me to bypass the check.
read more
9
Fix GIT Lock after GIT Crash
If you ever see the following message when trying to commit your code to a GIT repository.
If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.
2
Installing Zend Studio on Ubuntu 64-bit
Today I tried to install Zend Studio 7.0 on the latest 64-bit version of Ubuntu (9.10). Initially, it would just throw an error. (exec: 2481: /tmp/install.dir.2855/Linux/resource/jre/bin/java: not found). Since, the error was related to the installer not being able to find the java JRE that came bundled with the installer, I decided to install with the system’s JRE using:
./ZendStudio7_0_0.bin LAX_VM /usr/bin/java
That seemed to do the trick, but, once the installer had finished. Trying to open Zend Studio would give me an error (Failed to execute child process “/usr/local/Zend/Zend Studio-7.0.0/ZendStudio” (No such file or directory)). At this point I was about to give up, until I did a little bit of research and found that the problem was more simple that I imagined. read more
24
Maintaining PHP session when using CURL.
Working now on some iGoogle like dashboard for the system I’m developing.
I was trying some stuff out with CURL and was having a hard time to maintain my current session when making a curl request to another page. I needed to stay authenticated in order to retrieve my widget.
Here is my initial code:
$strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/'; $ch = curl_init($rssFeedLink); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt( $ch, CURLOPT_COOKIE, $strCookie ); $response = curl_exec($ch); curl_close($ch);
The problem with that piece of code is that it was generating a new session id instead of sending my current session.
The solution? read more


