Musician, Ruby on Rails Entusiast, Composer, Programmer and Lover of Hot Sauce

Convert MySql Datetime to Javascript Date Object

Posted: August 13th, 2009 | Author: mindtonic | Filed under: PHP | Tags: , | No Comments »
  function mysqlTimeStampToDate(timestamp) {
    //function parses mysql datetime string and returns javascript Date object
    //input has to be in this format: 2007-06-05 15:26:02
    var regex=/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9]) (?:([0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/;
    var parts=timestamp.replace(regex,"$1 $2 $3 $4 $5 $6").split(' ');
    return new Date(parts[0],parts[1]-1,parts[2],parts[3],parts[4],parts[5]);
  }

Source: http://snippets.dzone.com/posts/show/4132


Unit Testing Object Oriented PHP5 Code

Posted: July 1st, 2009 | Author: mindtonic | Filed under: PHP Testing | Tags: , , , , | No Comments »

I have been doing a lot for work with testing and development in Ruby. This has lead me to want to find an option to write Unit Tests for my own PHP based Content Management System, Shabda. It would be a very wise move to make sure that the core system files function exactly as expected. I will update this blog post as I go along.

My research has yielded two possible testing options:

SimpleTest

Other blogs with more information: http://vailo.wordpress.com/2008/07/03/php-unit-test-test-driven-development/


Installing PEAR php Packaging system on Wamp

Posted: July 1st, 2009 | Author: mindtonic | Filed under: PHP | Tags: , | No Comments »

I followed this easy tutorial: http://www.hiveminds.co.uk/node/3821/print and found the process to be painless. I think that all of my work with Ruby and the UNIX command line has made the idea of the windows command line a lot less scary!

To install some of the packages that I was trying to install PEAR for, I had to upgrade the PEAR installation. Fortunately, I am finding a lot of correlations between PEAR and Ruby GEMS. To update the PEAR installation itself, simply enter the following in a windows command prompt:

pear upgrade pear