There are various ways of validating dates in PHP or MySql, sometimes however you may just need to check if a given string is a valid MySql date string, outside of a form validator. One way to achieve this is to use a regular expression, the simple utility function below will accept a string and return true if it’s a valid MySql date.

Snippet

A useful function to generate a random string of a given length in php. The character source set is predefined, but can also be explicitly set. Can have multiple use cases, for example a unique identifier in an application or a handy utility for say a random password generator.

Snippet

There are various ways of retrieving a Magento category attribute, however depending on how it’s stored in the database you can’t always rely on the same method each time. This snippet will show you how to get the value of any Magento category attribute.

Snippet