Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

How To Make A Minutes Not Static?

jqeury date

  • Please log in to reply
1 reply to this topic

#1 Stasonix

Stasonix

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 115 posts
  • Programming Language:C++, PHP, JavaScript, Delphi/Object Pascal, Pascal
  • Learning:C++, PHP, JavaScript, Delphi/Object Pascal

Posted 11 June 2012 - 01:49 AM

I have a script that starting a seconds, also there is a minutes, but minutes is always static:

[color=#770088][font=Inconsolata, Monaco, Consolas,]var [/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]startTimeId[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,];[/font][/color]

[color=#770088][font=Inconsolata, Monaco, Consolas,]var [/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]zDate [/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]= [/font][/color][color=#770088][font=Inconsolata, Monaco, Consolas,]new [/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]Date[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]([/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,])[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,];[/font][/color]

[color=#770088][font=Inconsolata, Monaco, Consolas,]function [/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]startTime[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]([/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,])[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]{[/font][/color]
[color=#666666][font=Inconsolata, Monaco, Consolas,]	[/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]seconds [/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]= [/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]zDate[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,].[/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]getSeconds[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]([/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,])[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,];[/font][/color]
[color=#666666][font=Inconsolata, Monaco, Consolas,]	[/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]minutes [/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]= [/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]zDate[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,].[/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]getMinutes[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]([/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,])[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,];[/font][/color]

[color=#666666][font=Inconsolata, Monaco, Consolas,]	[/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]startTimeID [/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]= [/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]setInterval[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]([/font][/color][color=#770088][font=Inconsolata, Monaco, Consolas,]function[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]([/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,])[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]{[/font][/color]

[color=#666666][font=Inconsolata, Monaco, Consolas,]	[/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]seconds[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]++[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,];[/font][/color]
[color=#666666][font=Inconsolata, Monaco, Consolas,] [/font][/color]
[color=#770088][font=Inconsolata, Monaco, Consolas,]if[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]([/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]seconds[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]>[/font][/color][color=#228811][font=Inconsolata, Monaco, Consolas,]59[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]) [/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]{ [/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]seconds [/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]= [/font][/color][color=#228811][font=Inconsolata, Monaco, Consolas,]0[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]; [/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]}[/font][/color]

[color=#666666][font=Inconsolata, Monaco, Consolas,]				 [/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]$[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]([/font][/color][color=#AA2222][font=Inconsolata, Monaco, Consolas,]'#someDay'[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,])[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,].[/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]html[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]([/font][/color][color=#AA2222][font=Inconsolata, Monaco, Consolas,]'seconds: '[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]+[/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]seconds[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]+[/font][/color][color=#AA2222][font=Inconsolata, Monaco, Consolas,]' minutes: '[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]+[/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]minutes[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,])[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,];[/font][/color]
[color=#666666][font=Inconsolata, Monaco, Consolas,]	[/font][/color]
[color=#666666][font=Inconsolata, Monaco, Consolas,]	[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]}[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,],[/font][/color][color=#228811][font=Inconsolata, Monaco, Consolas,]1000[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,])[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,];	[/font][/color]
[color=#666666][font=Inconsolata, Monaco, Consolas,]	[/font][/color]
[color=#666666][font=Inconsolata, Monaco, Consolas,]}[/font][/color]

[color=#AA7700][font=Inconsolata, Monaco, Consolas,]// starting our time[/font][/color]
[color=black][font=Inconsolata, Monaco, Consolas,]startTime[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]([/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,])[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,];[/font][/color]

[color=#AA7700][font=Inconsolata, Monaco, Consolas,]// click on the element to set new seconds and minutes[/font][/color]
[color=black][font=Inconsolata, Monaco, Consolas,]$[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]([/font][/color][color=#AA2222][font=Inconsolata, Monaco, Consolas,]'#someDay'[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,])[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,].[/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]click[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]([/font][/color][color=#770088][font=Inconsolata, Monaco, Consolas,]function[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]([/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,])[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]{[/font][/color]


[color=#666666][font=Inconsolata, Monaco, Consolas,]	[/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]clearInterval[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]([/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]startTimeID[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,])[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,];[/font][/color]
[color=#666666][font=Inconsolata, Monaco, Consolas,]	[/font][/color]
[color=#666666][font=Inconsolata, Monaco, Consolas,]	[/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]zDate[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,].[/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]setSeconds[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]([/font][/color][color=#228811][font=Inconsolata, Monaco, Consolas,]45[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,])[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,];[/font][/color]
[color=#666666][font=Inconsolata, Monaco, Consolas,]	[/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]zDate[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,].[/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]setMinutes[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]([/font][/color][color=#228811][font=Inconsolata, Monaco, Consolas,]30[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,])[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,];[/font][/color]
[color=#666666][font=Inconsolata, Monaco, Consolas,]	[/font][/color]
[color=#666666][font=Inconsolata, Monaco, Consolas,]	[/font][/color][color=black][font=Inconsolata, Monaco, Consolas,]startTime[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,]([/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,])[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,];[/font][/color]
[color=#666666][font=Inconsolata, Monaco, Consolas,]	[/font][/color]

[color=#666666][font=Inconsolata, Monaco, Consolas,]}[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,])[/font][/color][color=#666666][font=Inconsolata, Monaco, Consolas,];[/font][/color]

[color=#000000][font=Inconsolata, Monaco, Consolas,]<[/font][/color][color=#AA00BB][font=Inconsolata, Monaco, Consolas,]div [/font][/color][color=#0000FF][font=Inconsolata, Monaco, Consolas,]id[/font][/color][color=#000000][font=Inconsolata, Monaco, Consolas,]=[/font][/color][color=#228811][font=Inconsolata, Monaco, Consolas,]"someDay"[/font][/color][color=#000000][font=Inconsolata, Monaco, Consolas,]>[/font][/color][color=#000000][font=Inconsolata, Monaco, Consolas,]</[/font][/color][color=#AA00BB][font=Inconsolata, Monaco, Consolas,]div[/font][/color][color=#000000][font=Inconsolata, Monaco, Consolas,]>[/font][/color][color=#000000][font=Inconsolata, Monaco, Consolas,]‚Äč[/font][/color]

How make a minutes also running?

And when I click on a div the script sets new values of minutes and seconds, after that they must run from setted values.

in the script possible to have any elemens of date type, such as days or a months etc.

I dont know what happen to this forum, but here is my jsfiddle: http://jsfiddle.net/Stasonix/PPhnG/
  • 0

#2 RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1311 posts
  • Location:C:\Countries\US
  • Programming Language:C, Java, C++, PHP, Python, JavaScript

Posted 11 June 2012 - 09:01 AM

Have you tried replacing this:
seconds   =   zDate  .  getSeconds  (  )  ;  

      minutes   =   zDate  .  getMinutes  (  )  ;  



      startTimeID   =   setInterval  (  function  (  )  {  



      seconds  ++  ;  

with this?:
seconds   =   zDate  .  getSeconds  (  )  ;  

      minutes   =   zDate  .  getMinutes  (  )  ;  



      startTimeID   =   setInterval  (  function  (  )  {  



      zDate.setTime (zDate.getTime () + 1000);  



      seconds   =   zDate  .  getSeconds  (  )  ;  

      minutes   =   zDate  .  getMinutes  (  )  ;  


  • 0
Regards,
RR





Also tagged with one or more of these keywords: jqeury, date

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download