Skip to content

mysql set variables, convert timestamp to date and substracting/adding time to a timestamp

SET @expired_timestamp = DATE_FORMAT(NOW() - INTERVAL 23 MINUTE, '%Y-%m-%d %H:%i:%s');
SET @valid_datetime = DATE_FORMAT((NOW() - INTERVAL 42 DAY), '%Y-%m-%d');

SELECT 
  `column_with_datetime`, 
  @expired_timestamp AS 'expired_timestamp', 
  @valid_datetime as 'valid_datetime'
FROM 
  `my_table` 
  WHERE 
    `column_with_datetime` >= @valid_datetime;
source

tool - php 5.3 - some new functions

Since php 5.4. throws his shadow i finally had some time to check the release notes of 5.3. Here are some changes that are made in PHP 5.3, i just picked up my favorits (as expected ;-) ). New Global Constants \_\_DIR\_\_ \_\_NAMESPACE\_\_ New Functions array_replace: replaces elements from passed arrays into the first array array_replace_recursive: replaces elements from passed arrays into the first array recursively class_alias: rreates an alias for a class header_remove: remove previously set headers I have not used one of this functions but since i am a developer i knew a lot of situations where this functons could have saved time. other changes to extensions cURL: cURL now supports SSH OpenSSL: OpenSSL digest and cipher functions are now supported. Session: Sessions will no longer store session-files in "/tmp" when open_basedir restrictions apply, unless "/tmp" is explicitly added to the list of allowed paths. new methods DateTime::add(): Adds an amount of days, months, years, hours, minutes and seconds to a DateTime object DateTime::diff(): Returns the difference between two DateTime objects. DateTime::sub(): Subtracts an amount of days, months, years, hours, minutes and seconds from a DateTime object.