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) Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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') Quote Link to comment 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"); Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.