Monday, 12 November 2012

Break MySQL formatted datetime

Well it has been MASSIVELY to long since I last posted anything here. I do have lots of plans on other posts to write, it's just finding the time. Now that the rock climbing session is over I'll hopefully be able to write more here.

So along side the PHP secure login class I'm making a utilities class (only just started) which will have just some generally useful methods. It's not a unified class so the methods in it can easily be copied out and put into another class or just as a plain old function.

Currently the only method I've added is one to break apart a MySQL datetime string into an array so you can display it in a different order to your users easily. I do have others made to add but they require a little more testing first.

Here is a link to the Google Code site which I just made so there's not much on it, just this method in a class and a short description of the class.

The only part which I've copied from someone else is the regular expression which validates the MySQL datetime string, I just don't understand regular expressions well enough to write my own of check this one but so far in my testing it seems to have worked. If you know something I don't feel free to leave a comment or get in contact with me!