thefollower Posted August 20, 2007 Share Posted August 20, 2007 Is there a command so that when the user registers itll post the exact date/time that it occured? Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/ Share on other sites More sharing options...
chocopi Posted August 20, 2007 Share Posted August 20, 2007 Do something like this: $date = date("d-m-Y H:i:sa",time()); echo $date; Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328839 Share on other sites More sharing options...
trq Posted August 20, 2007 Share Posted August 20, 2007 date(). Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328841 Share on other sites More sharing options...
thefollower Posted August 20, 2007 Author Share Posted August 20, 2007 right i put: $ip = $_SERVER["REMOTE_ADDR"]; $Gender = $_POST['Gender']; $Date = $Date("d-m-Y H:i:sa",time()); ip and gender work but not $Date, have i got the structure correct? Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328844 Share on other sites More sharing options...
chocopi Posted August 20, 2007 Share Posted August 20, 2007 get rid of the dollar sign $Date = $Date("d-m-Y H:i:sa",time()); to $Date = Date("d-m-Y H:i:sa",time()); This will echo 20-08-2007 16:28:46pm Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328845 Share on other sites More sharing options...
thefollower Posted August 20, 2007 Author Share Posted August 20, 2007 Ok will give it a try now my DB says : 0000-00-00 00:00:00 do you want me to show you the reg code as to how i input it? Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328848 Share on other sites More sharing options...
chocopi Posted August 20, 2007 Share Posted August 20, 2007 Please Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328852 Share on other sites More sharing options...
thefollower Posted August 20, 2007 Author Share Posted August 20, 2007 //connect and all that nonsense $Username = mysql_real_escape_string($_POST['Username']); $Password = mysql_real_escape_string($_POST['Password']); $Password2 = mysql_real_escape_string($_POST['Password2']); $Email = mysql_real_escape_string($_POST['EmailRegistration']); $Country = mysql_real_escape_string($_POST['CountryChoice']); $ip = $_SERVER["REMOTE_ADDR"]; $Gender = $_POST['Gender']; $Date = Date("d-m-Y H:i:sa",time()); //check if username etc is valid then i have: $query = "INSERT INTO `userregistration` (Username,Password,Email,Country,IP,Gender,RegisterDate) Values ('$Username', '$Password', '$Email', '$Country', '$ip', '$Gender', '$Date')"; mysql_query($query) or die(mysql_error()); these are the only 2 parts i have changed the rest of the code is all validation. Also if that looks ok ^ could it be my actual field? This is what i have in my table for userregistration: Field Name: RegisterDate Type : TimeStamp Attributes : On Update Current Time Stamp Not Null Default : CURRENT_TIMESTAMP is ticked on. thats it. Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328863 Share on other sites More sharing options...
chocopi Posted August 20, 2007 Share Posted August 20, 2007 oh sorry i gave you the wrong syntax it should be $date = date("Y-m-d H:i:a",time()); I think that should work ~ Chocopi Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328871 Share on other sites More sharing options...
thefollower Posted August 20, 2007 Author Share Posted August 20, 2007 still comes in as : 0000-00-00 00:00:00 Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328878 Share on other sites More sharing options...
chocopi Posted August 20, 2007 Share Posted August 20, 2007 $date = date('YmdHia'); Sorry I was thinking of something different EDIT ^^^ Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328880 Share on other sites More sharing options...
thefollower Posted August 20, 2007 Author Share Posted August 20, 2007 damn it still says: 0000-00-00 00:00:00 Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328886 Share on other sites More sharing options...
chocopi Posted August 20, 2007 Share Posted August 20, 2007 have you checked my edit above Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328887 Share on other sites More sharing options...
thefollower Posted August 20, 2007 Author Share Posted August 20, 2007 yeh Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328890 Share on other sites More sharing options...
chocopi Posted August 20, 2007 Share Posted August 20, 2007 well thats the code I use, so I am stumped Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328899 Share on other sites More sharing options...
thefollower Posted August 20, 2007 Author Share Posted August 20, 2007 can you show me yours if you dont mind ? i can compare it then Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328902 Share on other sites More sharing options...
lemmin Posted August 20, 2007 Share Posted August 20, 2007 This should work. date("Y-m-d H:i:s") Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328904 Share on other sites More sharing options...
itsmeArry Posted August 20, 2007 Share Posted August 20, 2007 use this $Date = date("d-m-Y H:i:s",time()); Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328919 Share on other sites More sharing options...
thefollower Posted August 20, 2007 Author Share Posted August 20, 2007 0000-00-00 00:00:00 still shows in my table Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328938 Share on other sites More sharing options...
chocopi Posted August 20, 2007 Share Posted August 20, 2007 I think the problem has got something to do with your table, seeing as the code you are being given should work. So check you have the right tablename, fieldname etc Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328944 Share on other sites More sharing options...
itsmeArry Posted August 20, 2007 Share Posted August 20, 2007 use this $Date = date("Y-m-d H:i:s",time()); Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328950 Share on other sites More sharing options...
thefollower Posted August 20, 2007 Author Share Posted August 20, 2007 use this $Date = date("Y-m-d H:i:s",time()); works ^ thankyou what did you change? Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328957 Share on other sites More sharing options...
itsmeArry Posted August 20, 2007 Share Posted August 20, 2007 just changed this d-m-Y to Y-m-d Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328960 Share on other sites More sharing options...
chocopi Posted August 20, 2007 Share Posted August 20, 2007 oh sorry i gave you the wrong syntax it should be $date = date("Y-m-d H:i:a"); I think that should work ~ Chocopi Bugger I posted that one earlier, but accidently deleted s instead of a Quote Link to comment https://forums.phpfreaks.com/topic/65817-solved-register-inputs-current-datetime/#findComment-328961 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.