Jump to content

Forward Timestamps


dark dude

Recommended Posts

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?
Link to comment
https://forums.phpfreaks.com/topic/15297-forward-timestamps/
Share on other sites

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:00

Any assistance for this bit?

It should read the date off the database as 10,000 days into the future, not the beginning of time...
Link to comment
https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-62006
Share on other sites

[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
Link to comment
https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-62075
Share on other sites

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
Link to comment
https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-62076
Share on other sites

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)
Link to comment
https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-63989
Share on other sites

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]<?php
echo 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
Link to comment
https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-64884
Share on other sites

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]
Link to comment
https://forums.phpfreaks.com/topic/15297-forward-timestamps/#findComment-65086
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.