How would I do this?

S

Scotty

I am designing a website and I want to have some text that says "Day 1" and
then each day at midnight (GMT+10 if possible) the text will change to "Day
2" then the next day "Day 3" and so on. How would I go about doing this?
Can anyone point me towards a website where I can learn how to do this?
Thanks,
Scott
 
B

Blinky the Shark

Scotty said:
I am designing a website and I want to have some text that says "Day 1" and
then each day at midnight (GMT+10 if possible) the text will change to "Day
2" then the next day "Day 3" and so on. How would I go about doing this?
Can anyone point me towards a website where I can learn how to do this?
Thanks,

Looking at a function list for PHP, it looks like you could do some
date math there.
 
B

Blinky the Shark

Ok, now i have to learn PHP :)

Well, not if you know perl or something else that will do the same thing
for you. :) Hell, I don't know any js; maybe you can do it there.
 
S

Scotty

Blinky the Shark said:
Well, not if you know perl or something else that will do the same thing
for you. :) Hell, I don't know any js; maybe you can do it there.

I know nothing beyond HTML. This is my problem.
 
B

Blinky the Shark

I know nothing beyond HTML. This is my problem.

Well, in the meantime I did a little work with in that book I mentioned
earlier. :)

http://blinkynet.net/scratch/datemath.html

*IF* your server does *PHP*, and *IF* it's set up to hand off your .html
pages to PHP for parsing[1], these two lines will do the job:

<?php print "Scotty's web site has been up for ";
print floor((time()-strtotime("10 May 2004"))/86400)." days."; ?>

A. You can reword what's now between the first two quotation marks.

B. Change the date to whatever you need; keep that format.

C. No, you won't see those lines if you look at source for my page.
That's the idea; the script has done its job unseen and returned
the text you see.


[1]Quite probably it won't be. Trying renaming the page on which you use
this code to have a .php extension. (Again, this is if your server does
PHP in the first place.)
 
S

Scotty

Blinky the Shark said:
Well, in the meantime I did a little work with in that book I mentioned
earlier. :)

http://blinkynet.net/scratch/datemath.html

*IF* your server does *PHP*, and *IF* it's set up to hand off your .html
pages to PHP for parsing[1], these two lines will do the job:

<?php print "Scotty's web site has been up for ";
print floor((time()-strtotime("10 May 2004"))/86400)." days."; ?>

A. You can reword what's now between the first two quotation marks.

B. Change the date to whatever you need; keep that format.

C. No, you won't see those lines if you look at source for my page.
That's the idea; the script has done its job unseen and returned
the text you see.


[1]Quite probably it won't be. Trying renaming the page on which you use
this code to have a .php extension. (Again, this is if your server does
PHP in the first place.)

Thanks heaps blinky! My host does PHP. I use flexihostings. I don't know
if is setup for parsing though. I'll try it out in a few minutes.

Can you explain to me how that works? Why do you have /86400?

thanks again!!!
 
S

Scotty

Ok, that worked when I changed the extension to .php
Is there anyway I can make it display in a certain text? If the rest of my
text is a certain style can I make the text inside that php the same style?
Thanks heaps for this
 
J

Jan Roland Eriksson

[...]
<?php print "Scotty's web site has been up for ";
print floor((time()-strtotime("10 May 2004"))/86400)." days."; ?>
[...]

Can you explain to me how that works? Why do you have /86400?

60 * 60 * 24 = 86400 seconds in a full 24 hour day.
 
S

Scotty

Blinky the Shark said:
Well, in the meantime I did a little work with in that book I mentioned
earlier. :)

http://blinkynet.net/scratch/datemath.html

*IF* your server does *PHP*, and *IF* it's set up to hand off your .html
pages to PHP for parsing[1], these two lines will do the job:

<?php print "Scotty's web site has been up for ";
print floor((time()-strtotime("10 May 2004"))/86400)." days."; ?>

A. You can reword what's now between the first two quotation marks.

B. Change the date to whatever you need; keep that format.

C. No, you won't see those lines if you look at source for my page.
That's the idea; the script has done its job unseen and returned
the text you see.


[1]Quite probably it won't be. Trying renaming the page on which you use
this code to have a .php extension. (Again, this is if your server does
PHP in the first place.)

I forgot to ask. What time zone does this use?
 
S

Scotty

Scotty said:
Ok, that worked when I changed the extension to .php
Is there anyway I can make it display in a certain text? If the rest of
my text is a certain style can I make the text inside that php the same
style?
Thanks heaps for this

I worked out how to make it bold.
I really appreciate this mate.
I'm just confused as to when the number will tick over.
 
B

Blinky the Shark

I worked out how to make it bold.
I really appreciate this mate.
I'm just confused as to when the number will tick over.

It counts days; it will change every day.
 
B

Blinky the Shark

Scotty said:
Blinky the Shark said:
Well, in the meantime I did a little work with in that book I mentioned
earlier. :)
http://blinkynet.net/scratch/datemath.html
*IF* your server does *PHP*, and *IF* it's set up to hand off your .html
pages to PHP for parsing[1], these two lines will do the job:
<?php print "Scotty's web site has been up for ";
print floor((time()-strtotime("10 May 2004"))/86400)." days."; ?>
A. You can reword what's now between the first two quotation marks.
B. Change the date to whatever you need; keep that format.
C. No, you won't see those lines if you look at source for my page.
That's the idea; the script has done its job unseen and returned
the text you see.
[1]Quite probably it won't be. Trying renaming the page on which you use
this code to have a .php extension. (Again, this is if your server does
PHP in the first place.)
I forgot to ask. What time zone does this use?

The time at your server, because that's what's running the script.
 
B

Blinky the Shark

Scotty said:
Ok, that worked when I changed the extension to .php Is there anyway I
can make it display in a certain text? If the rest of my text is a
certain style can I make the text inside that php the same style?
Thanks heaps for this

Simple answer: treat the script (as a whole; don't mess around inside
it) as you would any text, because that's what it's delivering -- wrap
it with whatever kind of styling you wish.
 
B

Blinky the Shark

Scotty said:
Can you explain to me how that works? Why do you have /86400?


floor((time()-strtotime("10 May 2004"))/86400)




time() = number of seconds since 1 Jan 1970 as of today

minus

strtotime("10 May 2004") = number of seconds between *that* date and
1 January 1970

gives the number of seconds between 10 May 2004 and today, which we
then divide by the number of seconds in a day to get the *day* count.
We don't want fractional part of a day, so

floor( that result )

gives us the integer part, IOW the part to the left of the decimal
point.
 
B

Blinky the Shark

Scotty said:
thanks again!!!

[Second reply to this]

I just noticed that in your OP you asked for specific wording. I was
just giving you an example, and didn't deliver that specific wording.

Here's the code for your actual request of "Day x":

<?php print "Day ";
print floor((time()-strtotime("10 May 2003"))/86400); ?>

(I just removed the "days" from after the output number and changed
what comes before it.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top