Zend Framework – Disable Layout and View from Rendering (Handy for AJAX)

I don’t know how many times I have needed to look this up for myself, typically when I am putting together a controller action that I want to use specifically for outputting something like JSON for some AJAX related thing I am doing. That or when I am working on a page that I need to have different from the base template that I have setup in my layouts. Either way, figured I’d post it here like the rest of the code I tend to reuse often, and share with the world cause they may be looking for it too.
Continue reading

JavaScript and PHP unix timestamp for right now, and a date of your choice

From time to time I find myself in need of knowing what the current epoch timestamp is, either in javascript or in php. More times then less I also find myself recreating a similar function to determine either respectively for either language. But sometimes I find it just so much more easier to have a pre-made function that I can either just see what that number is by going to a bookmark in my browser and getting the equivalent of now for my needs. Or in the event I need to future date something I just want the number. So I am making this simple little form for my benifit but figure so many of you will also enjoy it. Any feedback is welcome.
Continue reading

PHP Strong Password

If you want to prompt your users to create password that is a certain length more or less, that is also strong by today’s definition then here is a good example. This can be elaborated on even more but for common use in most practices this is more than enough. You can comment out like I have in the example below one or more if-else statements if you wish to not enforce that particular type. In my example I commented out the need for symbols like @ # $ &… What this function out of the box seeks is at least 1 letter and 1 number, it seeks to make sure at least 1 letter is capitalized and wants the password to be more than 8 char long but less than 20. This function returns true/false. False if the password has passed the requirements true if not. An example of its use would be
Continue reading

PHP Unix TimeStamp to mySQL DATETIME

Sometimes you jut want to have a ready need to take a recalculated timestamp from a past/future date and store it in your DB this little function helps achieve that, I notice a lot of people especially newer coders who have a passion for time() timestamps as they are in a sense easier to work with, but at the end of the day don’t know how to switch it over to a mySQL friendly datetime format Example:

TimeStamp: 1306193250 converts to MySQL DATETIME: 2011-05-23 19:27:30
TimeStamp: converts to MySQL DATETIME:

Now some may argue that its a bit redundant to have this in function format as all it really is, is one line of code, however I keep it as a function to remember it easier. When the time comes to use it rather than type everything all out time and time again. But thats just me.

function unixToMySQL($timestamp)
	return date('Y-m-d H:i:s', $timestamp);