[Code Help]General code help?[PHP] (12)

1 Name: #!/usr/bin/anonymous : 2014-04-16 17:06 ID:tTTThWto This thread was merged from the former /code/ board. You can view the archive here.

I was running a textboard that has custom software. It has gone down due to reasons beyond my control (got a new router, AT&T won't let me port forward like I was able to do before). Anyways, in the event I can open ports again, I would like to add something to the script. How could I add an Eternal September post date like on DQN? Would I have to play with date()?

2 Name: #!/usr/bin/anonymous : 2014-04-17 00:53 ID:Heaven

You probably would have to write your own date function based on PHP's date(). For example if you wanted to stay on 2000 and we have 2014 then you'd have to add (2014-2000)*12 months to your month count. But since you want an eternal september you'd have to calculate 14*12*30 days instead. It's actually really easy.

3 Name: #!/usr/bin/anonymous : 2014-04-17 06:10 ID:Heaven

php is shit

4 Name: #!/usr/bin/anonymous : 2014-04-19 21:22 ID:Heaven

Ok, thank you >>2
I know, >>3, I can't be botherd to learn anything else.

5 Name: #!/usr/bin/anonymous : 2014-04-19 22:52 ID:Heaven

>>4
Everything else is shit. But not quite as shit as php. php is a magnificent example of a shitty programming language. However, despite being a total pile of shit you may still achieve satori while using it. As a architectural genius may realize er abilities when stacking blocks of cow dung. After years of toiling with shit, ey will find bricks and concrete, and ey will wounder why the building blocks don't naturally stick together and emit the familiar odor.

6 Name: #!/usr/bin/anonymous : 2014-04-19 23:48 ID:Heaven

>>5
Thank you for that depressing view on languages.

7 Name: #!/usr/bin/anonymous : 2014-04-20 06:44 ID:Heaven

>>6
Don't take it too seriously. Everything is shit in the sense that everything is inadequate at expression in one way or another. But what formal language could possibly compare to the extent of a person's imagination? Nothing.

8 Name: #!/usr/bin/anonymous : 2014-04-21 18:59 ID:07R5RuIa

wouldn't you do?
`$date = Date('2003-09-d')
so that todays date (21st) would say 2003-09-21

9 Name: #!/usr/bin/anonymous : 2014-04-21 19:00 ID:07R5RuIa

*without the backtick. thought that would turn the line into monotype like on ascii boards

10 Name: #!/usr/bin/anonymous : 2014-04-25 19:32 ID:x9BsBbjb

Ok, so based on what >>2-san gave me, this is what I came up with:

$days=21*12*30;//21 because it's been 21 years since 1993
$date = date("1993-09-$days);
echo $date;
Would this be correct? Because every time I check http://www.eternal-september.org/ I'm off by 18 days.

11 Name: #!/usr/bin/anonymous : 2014-04-26 12:57 ID:VhMy9ojj

>>8
Days accumulate. I.e. we're on day 7543 today (september 1993).
>>9
You need to match the opening backtick with a closing backtick. On your post form, click More options..., there is an option box for Formatting:. The default is WakabaMark, see docs here http://wakaba.c3.cx/docs/docs.html#WakabaMark
>>10
$days is a constant and not a variable! I.e. it does not depend on the actual date. How can it possibly update?
You'd first need to retrieve the current date, for example 26/4/2014.
Then you calculate

#        20 years         3 months     current month
$days = (2013-1993)*365 + 3*30 + 26;

But this is a rough calculation that is not correct. The first problem is that not all months have 30 days, and the second is that not all years have 365 days.

Another way is to use the unix epoch and the function mktime. For example, (with comments for your convenience)

# set the timezone with
# date_default_timezone_set()
# if necessary
$zerotime = mktime(0, 0, 0, 9, 0, 1993); # Unix epoch of September 1993 day 1 time 00:00
$currtime = time(); # Current Unix epoch
$difftime = $currtime - $zerotime; # seconds passed since September 1993, day 1 time 00:00.
$days = $difftime / 60 / 60 / 24; # seconds to days
print "Today is September, $days 1993, the september that never ends"

That should give you an accurate date for eternal september. See http://en.wikipedia.org/wiki/Unix_time for details on Unix epoch time.

12 Name: #!/usr/bin/anonymous : 2014-04-26 22:37 ID:gCTBJ7nM

>>11
Thank you! To be honest, I didn't know much about mktime(). But now the function makes sense. Your code works perfectly, thank you. I'm just working on removing everything after the decimal.

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification: