Handles datetime in buildQuery for PHP >= 5.4