dark dude Posted July 21, 2006 Share Posted July 21, 2006 I can't seem to get the following to work...[quote]if($Category=='Multi'){$Banlength = UNIX_TIMESTAMP(NOW()) + 864000000;echo $Banlength;} else {echo 'I r t3h h4x';}[/quote]It should return 10,000 days into the future if the category is multi, but it doesnt... It doesnt print anything except the usual page markup (So it's not a fault in php).Anybody got any advice? Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/ Share on other sites More sharing options...
kenrbnsn Posted July 21, 2006 Share Posted July 21, 2006 UNIX_TIMESTAMP and NOW are MySQL functions not PHP function, try:[code]<?php$Banlength = time() + 864000000;echo $Banlength;?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-61911 Share on other sites More sharing options...
dark dude Posted July 22, 2006 Author Share Posted July 22, 2006 Ok, so far so good, but I want to know how to put that into a database, with its field-type as "timestamp".At the moment, I input it like this:[code]$query="UPDATE Users SET Status='Banned', BannedBy='$Username', BannedOn=CURRENT_TIMESTAMP(NOW()), BannedFor='$Banreason', BannedUntil='$Banlength' WHERE Username='$Victim'";mysql_query($query);[/code]and when it's put on the databse, it reads on the database that they're banned until 0000-00-00 00:00:00Any assistance for this bit?It should read the date off the database as 10,000 days into the future, not the beginning of time... Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-62006 Share on other sites More sharing options...
kenrbnsn Posted July 22, 2006 Share Posted July 22, 2006 That's because your field is not type timestamp, but type datetime.BTW, if you had asked the original question in the context of MySQL, like you just did above, you would have gotten a different answer.Ken Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-62068 Share on other sites More sharing options...
dark dude Posted July 22, 2006 Author Share Posted July 22, 2006 [quote author=kenrbnsn link=topic=101430.msg401667#msg401667 date=1153578631]That's because your field is not type timestamp, but type datetime.BTW, if you had asked the original question in the context of MySQL, like you just did above, you would have gotten a different answer.Ken[/quote]Oh sorry, my apologies.Also, it is type timestamp:http://img95.imageshack.us/img95/2646/timestampcs5.png Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-62075 Share on other sites More sharing options...
kenrbnsn Posted July 22, 2006 Share Posted July 22, 2006 Remove the default value from that field. Timestamp fields don't have a default value. That default value is for datetime fields. Either you put that default value in by mistake or you changed the field type from datetime to timestamp at some point and left the default value intact.Ken Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-62076 Share on other sites More sharing options...
dark dude Posted July 22, 2006 Author Share Posted July 22, 2006 I tried, but it wont let me change it to anything out of 0000-00-00 00:00:00 format :( Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-62174 Share on other sites More sharing options...
dark dude Posted July 23, 2006 Author Share Posted July 23, 2006 Offtopic: Also, is bumping topics legal? Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-62434 Share on other sites More sharing options...
kenrbnsn Posted July 23, 2006 Share Posted July 23, 2006 Yes, bumping is allowed, but only once about once a day (not more than twice a day).What tool are you using to manipulate the database. I us phpmyadmin. Can you post the table definition?Ken Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-62490 Share on other sites More sharing options...
dark dude Posted July 26, 2006 Author Share Posted July 26, 2006 Yea, I use phpmyadmin, the table definition?I think that's this right?: BannedUntil timestamp No 0000-00-00 00:00:00 Browse distinct values Change Drop Primary Unique Index Fulltext (Sorry for late reply, couldnt get to the internet because the modem died) Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-63989 Share on other sites More sharing options...
dark dude Posted July 26, 2006 Author Share Posted July 26, 2006 *Bumps - Second paged* Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-64203 Share on other sites More sharing options...
dark dude Posted July 27, 2006 Author Share Posted July 27, 2006 *bump* Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-64675 Share on other sites More sharing options...
wildteen88 Posted July 27, 2006 Share Posted July 27, 2006 Dont use TIMESTAMP as the datatype but use INT to store your timestamp, and set the length to 20. For some reason either phpmyadmin/mysql converts the timestamp into date/time form and doesnt keep the timestamp as numbers. Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-64689 Share on other sites More sharing options...
dark dude Posted July 27, 2006 Author Share Posted July 27, 2006 It's still only returning the year ???In the "BannedUntil" field on the entered row, it now says: 2033...Edit: Actually, I tried again and it's put 2018015467 into there... o.O Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-64696 Share on other sites More sharing options...
wildteen88 Posted July 27, 2006 Share Posted July 27, 2006 Did you change it to int? Also make sure the NULL column is set to 'null 'and not 'not null'. if its 'not null' it put in a defualt value. Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-64699 Share on other sites More sharing options...
dark dude Posted July 27, 2006 Author Share Posted July 27, 2006 Yeap, it's set to Int(20) and it's now set to NullHowever, it's still outputting the result 2018039464 into the field... Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-64862 Share on other sites More sharing options...
kenrbnsn Posted July 27, 2006 Share Posted July 27, 2006 That number is the number of second since 1-1-1970 of "today + 10000 days", which is what you wanted in the first place.To verify in PHP:[code]<?phpecho date('l, F j, Y G:i',time()+(10000 * 86400)).'<br>';echo date('l, F j, Y G:i',2018039464);?>[/code]You will see that the dates are close, since the number you posted is now 10000 days from a time in the past.Ken Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-64884 Share on other sites More sharing options...
wildteen88 Posted July 28, 2006 Share Posted July 28, 2006 Yeah, that number (2018039464) is a unix timestamp. If you follow kens example above you'll see how to convert that timestamp into a date using PHPs date function, (secound line in kens example above):[code=php:0]echo date('l, F j, Y G:i',2018039464);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-65086 Share on other sites More sharing options...
dark dude Posted July 28, 2006 Author Share Posted July 28, 2006 Ohhh, thanks a lot guys, that's solved my problem now ;D :) ;)~Dark dude~ Quote Link to comment https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-65096 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.