Hi, I'm using the function
$data=date_default_timezone_set("Y-m-d");
and I'm getting the date like 0000-00-00 in my table. Can any one help me ?
Hi, I'm using the function
$data=date_default_timezone_set("Y-m-d");
and I'm getting the date like 0000-00-00 in my table. Can any one help me ?
date_default_timezone_set
sets the default timezone and takes time zone identifier(e.g. "EST" or "EST5EDT").
After time zone is set you can use date
function to format datetime value.
date_default_timezone_set("GMT"); // timezone you want to use if you don't want the OS default timezone
$dt = date("Y-m-d");
date_default_timezone_set
receives a timezone identifier, not a date formatter.
You probably want something like date("Y-m-d")
.
date-default-timezone-set is used for setting a deafult timezone (like "Europe/Moscow"), not for setting date format. You might need to use "date('Y-m-d');"
Do you realize that you are providing a date format, not time zone? Proper argument would be in example "Europe/Prague", what you probably want is date() function
date_default_timezone_set()
is used to set the default timezone used by date and time functions.
Calling the function as $data=date_default_timezone_set("Y-m-d")
is wrong for two reasons:
TRUE
when the passed parameter is a valid timezone identifier, and FALSE
when it's not a valid identifier.'America/New_York'
.