pedrosorio Posted September 30, 2009 Share Posted September 30, 2009 I'm using this code: date_default_timezone_set("Europe/Lisbon"); $data=date("Y-M-D"); and all I get is 0000-00-00. (Using LAMP on ubuntu) Link to comment https://forums.phpfreaks.com/topic/176090-php-date-returns-0000/ Share on other sites More sharing options...
jon23d Posted September 30, 2009 Share Posted September 30, 2009 Are you echoing $data and getting that return value? Link to comment https://forums.phpfreaks.com/topic/176090-php-date-returns-0000/#findComment-927872 Share on other sites More sharing options...
cags Posted September 30, 2009 Share Posted September 30, 2009 When you say 'all I get' are we talking when you echo out the value? when you add it to a database? May be a stupid question, but you have the variable name as $data, your not trying to insert $date into a database are you? Link to comment https://forums.phpfreaks.com/topic/176090-php-date-returns-0000/#findComment-927873 Share on other sites More sharing options...
pedrosorio Posted September 30, 2009 Author Share Posted September 30, 2009 Are you echoing $data and getting that return value? Ok, you got me =X "2009-Sep-Wed" appears if I echo, I am inserting a record into a MySQL database. The field I'm inserting this into has type DATE. INSERT INTO Users VALUES ('$nome','$pass','$number','$data') Link to comment https://forums.phpfreaks.com/topic/176090-php-date-returns-0000/#findComment-927874 Share on other sites More sharing options...
cags Posted September 30, 2009 Share Posted September 30, 2009 It's realising it's an invalid date and adding the default value. What you want is this. date_default_timezone_set("Europe/Lisbon"); $data=date("Y-m-d"); Link to comment https://forums.phpfreaks.com/topic/176090-php-date-returns-0000/#findComment-927877 Share on other sites More sharing options...
pedrosorio Posted September 30, 2009 Author Share Posted September 30, 2009 It's realising it's an invalid date and adding the default value. What you want is this. date_default_timezone_set("Europe/Lisbon"); $data=date("Y-m-d"); I've tried changing the date format and achieved that result just before reading your post =) Thanks! Link to comment https://forums.phpfreaks.com/topic/176090-php-date-returns-0000/#findComment-927879 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.