Jump to content

elmerdev30

Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by elmerdev30

  1.  

    If the website displays the message and also a date/time stamp for each message -- then you could write Javascript to use that date/time stamp.

     

    If such a date/time stamp is not provided then the server-side code (probably Php) would need to be modified.

    Can you show me an example of a javascript for this? If it's not big enough of a request...

  2. You're going to need to store the starting time on the server side with a language like PHP and load that time onto the page for Javascript to use.

    Can you expound on how to do that?

    As I've said, I am new to css, html, etc.

    The website is built using bootstrap css and fontawesome, which I never have any idea. The developer only left me with that info and the ftp login.

    But now that you brought it up, I might as well search on how to store starting time on server side and study the php language.

     

    If you have may, perhaps, share a little info on how it should be done.

    Thanks.

  3.  

     

    Normally a post is going to be entered into a table in the database. That entry would include a timestamp. So it isn't clear to me what you are trying to do.

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>time</title>
    </head>
    <body>
    
    <p id="p1">Last update:
    <span id="hours">00</span>:<span id="minutes">00</span>:<span id="seconds">00</span>
    </p>
    
    <script>
    // This code is rather strange as it accumulates seconds and minutes and hours 
    // as independent semi-equivalent totals
    
            var hoursLabel = document.getElementById("hours");
            var minutesLabel = document.getElementById("minutes");
            var secondsLabel = document.getElementById("seconds");
            var totalSeconds = 0, totalMinutes = 0, totalHours = 0;
            setInterval(setTime, 1000);
    
            function setTime()
            {
    	    'use strict';
                ++totalSeconds;
                secondsLabel.innerHTML = pad(totalSeconds%60);
    			
    	    if (totalSeconds%60 == 0){
    			
    		++totalMinutes;
    		minutesLabel.innerHTML = pad(totalMinutes%60);
    				
    		if (totalMinutes%60 == 0){
    				
    		    ++totalHours;
    		    hoursLabel.innerHTML = pad(totalHours);
    		}
    	    }
            }
    
            function pad(val)
            {
               var valString = val + "";
                if(valString.length < 2)
                {
                    return "0" + valString;
                }
                else
                {
                    return valString;
    

     

    Hi dave, thank you for responding to my post.

     

    What I am actually trying to put here is a timer that counts up in hours, minutes and seconds. Say, for instance, by the time I click the 'Post' button to this reply, the time will begin to count up to (maximum) 24 hours, because I will be updating the site every single day. So, I know the gap in hours, minutes and seconds when the site was last updated.

     

    I admit the code was strange since I only added the minutes and hours based on the seconds, which is the original code I followed:

    ++totalSeconds;
                secondsLabel.innerHTML = pad(totalSeconds%60);
                minutesLabel.innerHTML = pad(parseInt(totalSeconds/60));
    

    Based on that, I formulated the minutes and hours, which resulted to this: http://screencast.com/t/Sy44tLESatc

    Obviously, the hours never showed a number, except '00' and the minutes went to over 100 and counting. However, when I refresh the page, the numbers of minutes and seconds also restart.

     

    I don't want it to refresh when I refresh the page or even if I close it. I want the counting to continue until the next day.

     

    I am hoping that this code you formulated is correct.

      {
    	    'use strict';
                ++totalSeconds;
                secondsLabel.innerHTML = pad(totalSeconds%60);
    			
    	    if (totalSeconds%60 == 0){
    			
    		++totalMinutes;
    		minutesLabel.innerHTML = pad(totalMinutes%60);
    				
    		if (totalMinutes%60 == 0){
    				
    		    ++totalHours;
    		    hoursLabel.innerHTML = pad(totalHours);
    		}
    	    }
            }
    

    The website is built using bootstrap css and fontawesome, which I never have any idea. The developer only left me ftp login. I was clueless what to do next, except to do google search, etc.

    Thanks to the tutorials at w3schools.com, I was able to find the timer tutorial and the members' posts on this forum. But I never found what I wanted so I created a new topic here.

     

    I don't know if I am allowed to put the site here so you'll know exactly what I mean. But, I think this screenshot

     

    As I've said, I don't have any background on css, javascript, or html. I just learned about the timer codes through the tutorials and other posts.

    So, I'm hoping to get some help. Please guys....

  4. Hi,

     

    I am new to html and css but I learned a thing or two through the tutorials.

    I am trying create a timer that indicates the last update of a post. So, the timer should count from 0 and stop when ever I update a new post. And, then, start the count again from 0.

     

    I was able to formulate one with the help of the tutorials, but I can't make it the way that I wanted. Instead, the timer automatically restarts when I refresh the page.

    Here's what I've made. I am not sure about the minutes and hours.

    <p id="p1">Last update:
    
    <label id="hours">00</label>:<label id="minutes">00</label>:<label id="seconds">00</label>
        <script type="text/javascript">
            var hoursLabel = document.getElementById("hours");
            var minutesLabel = document.getElementById("minutes");
            var secondsLabel = document.getElementById("seconds");
            var totalSeconds = 0;
            setInterval(setTime, 1000);
    
            function setTime()
            {
                ++totalSeconds;
                secondsLabel.innerHTML = pad(totalSeconds%60);
                minutesLabel.innerHTML = pad(parseInt(totalSeconds/60));
    
                ++totalMinutes;
                minutesLabel.innerHTML = pad(totalMinutes%60);
                hoursLabel.innerHTML = pad(parseInt(totalMinutes/60));
    
                ++totalHours;
                hoursLabel.innerHTML = pad(totalHours%24);
                hoursLabel.innerHTML = pad(parseInt(totalMinutes/60));
            }
    
            function pad(val)
            {
                var valString = val + "";
                if(valString.length < 2)
                {
                    return "0" + valString;
                }
                else
                {
                    return valString;
                }
            }
        </script></p>
    

    Could anyone help me out with how to make this not restart whenever the page is refreshed?

     

    I would really appreciate your help.

     

    Thanks.

     

  5. Hi, newbie here!

     

    I'm elmerdev30. I join this forum in order to know more about html or css languages.

    I never have any html or css background. I never even went to programming school. However, I am amazed at the websites my friends created. I tried to ask them myself if they could teach me but they only give me teach-you-later answers. Then, I came across w3schools tutorials. It's fun knowing and testing the html and/or css codes.

     

    I wish to be cognizant enough of this field, no matter how complex it is and how long it would take me to.

     

    cool stuff :)

×
×
  • Create New...