Category: PHP

  • Laravel, time zones and carbon

    Laravel defaults to storing all dates in UTC format, this is highly recommended as UTC time never changes unlike other time zones which have daylight savings. It is best practice to store and read dates in UTC, and then convert UTC to your required time zone for the user interface.

    Great article below of a good way to implement time zones using Carbon within your Laravel app.

    https://andrew.cool/blog/49/Easy-timezones-in-Laravel-with-Carbon

  • PHP: Show PHP errors messages for debugging code

    PHP: Show PHP errors messages for debugging code

    Need to easily debug some php code? simple add the following code to your script to enable PHP error reporting and display error messages. This allows you to quickly debug without making configuration changes to servers PHP configuration.

    It is good practice to hide error messages for security reasons, error messages could be used by hackers to gather information and vulnerabilities.

    This code is provided as it and may require changes to work for your needs.

  • PHP: Random sequence function

    PHP: Random sequence function

    Here is a function I have created which is used to generate a sequence of random numbers, letters and symbols. I currently use it on a number of projects including http://passworded.co.uk which is a simple password generator. (more…)