How would I do this?

Discussion in 'HTML' started by Scotty, May 10, 2005.

  1. Scotty

    Scotty Guest

    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
    Scotty, May 10, 2005
    #1
    1. Advertising

  2. Scotty wrote:
    > 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.


    --
    Blinky Linux Registered User 297263
    Killing all Usenet posts from Google Groups
    Info: http://blinkynet.net/comp/uip5.html
    Blinky the Shark, May 10, 2005
    #2
    1. Advertising

  3. Scotty

    Scotty Guest

    "Blinky the Shark" <> wrote in message
    news:...
    > Looking at a function list for PHP, it looks like you could do some
    > date math there.


    Ok, now i have to learn PHP :)
    Scotty, May 10, 2005
    #3
  4. Scotty wrote:

    > "Blinky the Shark" <> wrote in message
    > news:...


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


    > 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.

    --
    Blinky Linux Registered User 297263
    Killing all Usenet posts from Google Groups
    Info: http://blinkynet.net/comp/uip5.html
    Blinky the Shark, May 10, 2005
    #4
  5. Scotty

    Scotty Guest

    "Blinky the Shark" <> wrote in message
    news:...
    > 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.
    Scotty, May 10, 2005
    #5
  6. Scotty wrote:

    > "Blinky the Shark" <> wrote in message
    > news:...


    >> 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.


    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.)

    --
    Blinky Linux Registered User 297263
    Killing all Usenet posts from Google Groups
    Info: http://blinkynet.net/comp/uip5.html
    Blinky the Shark, May 10, 2005
    #6
  7. Scotty

    Scotty Guest

    "Blinky the Shark" <> wrote in message
    news:...
    > 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!!!
    Scotty, May 10, 2005
    #7
  8. Scotty

    Sid Ismail Guest

    On Tue, 10 May 2005 07:37:57 GMT, "Scotty" <> wrote:

    :
    : "Blinky the Shark" <> wrote in message
    : news:...
    : > Looking at a function list for PHP, it looks like you could do some
    : > date math there.
    :
    : Ok, now i have to learn PHP :)


    Some excellent ready-made javascript scripts here:
    http://www.dynamicdrive.com/

    Sid
    Sid Ismail, May 10, 2005
    #8
  9. Scotty

    Scotty Guest

    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
    Scotty, May 10, 2005
    #9
  10. On Tue, 10 May 2005 10:02:28 GMT, "Scotty" <> wrote:

    >"Blinky the Shark" <> wrote in message
    >news:...


    [...]

    >> <?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.

    --
    Rex
    Jan Roland Eriksson, May 10, 2005
    #10
  11. Scotty

    Scotty Guest

    "Blinky the Shark" <> wrote in message
    news:...
    > 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?
    Scotty, May 10, 2005
    #11
  12. Scotty

    Scotty Guest

    "Scotty" <> wrote in message
    news:XZ0ge.8730$...
    > 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.
    Scotty, May 10, 2005
    #12
  13. Scotty

    Andy Dingley Guest

    On Tue, 10 May 2005 07:37:57 GMT, "Scotty" <> wrote:

    >Ok, now i have to learn PHP :)


    Good. It won't hurt, it's useful and this level of PHP won't take more
    time than a cup of coffee to learn.
    Andy Dingley, May 10, 2005
    #13
  14. Scotty wrote:
    > "Scotty" <> wrote in message
    > news:XZ0ge.8730$...
    >> 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.


    It counts days; it will change every day.

    --
    Blinky Linux Registered User 297263
    Killing all Usenet posts from Google Groups
    Info: http://blinkynet.net/comp/uip5.html
    Blinky the Shark, May 10, 2005
    #14
  15. Scotty wrote:
    > "Blinky the Shark" <> wrote in message
    > news:...
    >> 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.

    --
    Blinky Linux Registered User 297263
    Killing all Usenet posts from Google Groups
    Info: http://blinkynet.net/comp/uip5.html
    Blinky the Shark, May 10, 2005
    #15
  16. Scotty wrote:
    > 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.

    --
    Blinky Linux Registered User 297263
    Killing all Usenet posts from Google Groups
    Info: http://blinkynet.net/comp/uip5.html
    Blinky the Shark, May 10, 2005
    #16
  17. Scotty wrote:

    > 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.


    --
    Blinky Linux Registered User 297263
    Killing all Usenet posts from Google Groups
    Info: http://blinkynet.net/comp/uip5.html
    Blinky the Shark, May 10, 2005
    #17
  18. Scotty wrote:

    > 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.)

    --
    Blinky Linux Registered User 297263
    Killing all Usenet posts from Google Groups
    Info: http://blinkynet.net/comp/uip5.html
    Blinky the Shark, May 10, 2005
    #18
  19. In article <>,
    Blinky the Shark <> wrote:
    >
    > floor( that result )
    >
    > gives us the integer part, IOW the part to the left of the decimal
    > point.


    <pedant>Not if 'that result' is less than zero.</pedant>

    --
    Joel.
    Joel Shepherd, May 11, 2005
    #19
  20. Scotty

    Scotty Guest

    Thanks so much for all of your help Blinky!
    Scotty, May 11, 2005
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pete M
    Replies:
    8
    Views:
    565
    Joe Smith
    Jun 18, 2004
  2. SSP
    Replies:
    5
    Views:
    844
  3. MS Office Guy

    Would like to learn asp.net, ado.net

    MS Office Guy, Aug 16, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    331
    Gönen EREN
    Aug 16, 2003
  4. greg
    Replies:
    0
    Views:
    436
  5. Robbo
    Replies:
    2
    Views:
    286
    Robbo
    Oct 30, 2003
Loading...

Share This Page