El error que te está apareciendo es un E_STRICT causado por date(). Dice la documentación de date:
"Every call to a date/time function will generate a E_NOTICE if the time zone is not valid, and/or a E_STRICT message if using the system settings or the TZ environment variable. See also date_default_timezone_set()"
"Toda llamada a una función de fecha/hora generará un E_NOTICE si la franja horaria no es válida y/o un E_STRICT si se ha usado la configuración del sistema o la variable de entorno. Ver también date_default_timezone_set()"
De hecho, si configuras como E_STRICT verás que dice:
Cita: PHP Strict Standards: date(): It is not safe to rely on the system's timezone s
ettings. Please use the date.timezone setting, the TZ environment variable or th
e date_default_timezone_set() function. In case you used any of those methods an
d you are still getting this warning, you most likely misspelled the timezone id
entifier. We selected 'Europe/Paris' for '2.0/DST' instead in C:\2.php on line 17
Ahora bien... ¿Por qué en un caso se enmascara y en el otro no? No lo puedo asegurar, pero diría que es por la asignación. Hacer date("Y-m-j"); deja subir el aviso, pero $fecha = date("Y-m-j"); lo suprime.