SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member Pufftenticle's Avatar
    Join Date
    Sep 2004
    Location
    round rock, texas
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Changing the time within a script

    Hi,

    I use this small script to auto change the shift (or crew) that is on duty on the front of a website. This is in the header:

    Code:
    <script language="JavaScript">
    	var days;
    	var difference;
    	var shift;
    	ADay = new Date("March,2 2003");
    	today = new Date();
    	difference = today-ADay;
    	days = Math.floor(difference/(1000*60*60*24));
    	diff = days % 3;
    	if(diff==0)
    		shift=" 'B' ";
    	else if(diff==1)
    		shift=" 'C' ";
    	else shift=" 'A' ";
    	</script>
    <script language="javascript" type="text/javascript">
    <!--
    var mon = new Array("January","February","March","April","May","June","July","August","September","October","November","December"); 
    var day = new Date; 
    var yr = day.getYear();
    
    if(yr < 2000) 
    {
    	yr = yr + 1900; 
    }
    
    var sho = "<p> " + mon[day.getMonth()] + "&nbsp;" + day.getDate() + ",&nbsp;" + yr + "</b></p>"; // change formatting as required
    //-->
    </script>
    and this is at the point in the site:

    Code:
    <script language="JavaScript">
    	var days;
    	var difference;
    	var shift;
    	ADay = new Date("March,2 2003");
    	today = new Date();
    	difference = today-ADay;
    	days = Math.floor(difference/(1000*60*60*24));
    	diff = days % 3;
    	if(diff==0)
    		shift=" 'B' ";
    	else if(diff==1)
    		shift=" 'C' ";
    	else shift=" 'A' ";
    	</script>
    the script changes the crew (or makes the shift change time) at midnight. how can i change that to the actual time that the shift changes ?

    here is the site (script is over on the left side): http://www.jvfd.org

    thanks

  2. #2
    SitePoint Member Pufftenticle's Avatar
    Join Date
    Sep 2004
    Location
    round rock, texas
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    any help ? thanks

  3. #3
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I didn't really look into this, but I saw this
    Code:
    var yr = day.getYear();
    
    if(yr < 2000) 
    {
    	yr = yr + 1900; 
    }
    You don't need to do this check, use getFullYear instead. getYear is deprecated.

  4. #4
    SitePoint Member Pufftenticle's Avatar
    Join Date
    Sep 2004
    Location
    round rock, texas
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    okay... thanks !


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •