JavaScript needed in determining seconds elapsed in current year starting Jan 01 at 00:00 [on hold]How to determine equality for two JavaScript objects?Why would a JavaScript variable start with a dollar sign?Get the current URL with JavaScript?How do I get the current date in JavaScript?Why does the JavaScript need to start with “;”?Get current date/time in secondsGet the current year in JavaScriptGetting current date and time in JavaScriptGetting a MySQL DateTime in PHP to seconds in javascriptJavascript, counting years and days since 1970-01-01 until today

Electoral considerations aside, what are potential benefits, for the US, of policy changes proposed by the tweet recognizing Golan annexation?

Non-trope happy ending?

Fear of getting stuck on one programming language / technology that is not used in my country

Are Captain Marvel's powers affected by Thanos' actions in Infinity War

Multiplicative persistence

Biological Blimps: Propulsion

What should you do if you miss a job interview (deliberately)?

How do I delete all blank lines in a buffer?

Does an advisor owe his/her student anything? Will an advisor keep a PhD student only out of pity?

How to explain what's wrong with this application of the chain rule?

Why "had" in "[something] we would have made had we used [something]"?

How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?

What exactly color does ozone gas have?

What if you are holding an Iron Flask with a demon inside and walk into Antimagic Field?

What are some good ways to treat frozen vegetables such that they behave like fresh vegetables when stir frying them?

What if a revenant (monster) gains fire resistance?

Can disgust be a key component of horror?

Can I still be respawned if I die by falling off the map?

Has any country ever had 2 former presidents in jail simultaneously?

What to do when eye contact makes your subordinate uncomfortable?

Does malloc reserve more space while allocating memory?

What does "Scientists rise up against statistical significance" mean? (Comment in Nature)

Open a doc from terminal, but not by its name

How should I respond when I lied about my education and the company finds out through background check?



JavaScript needed in determining seconds elapsed in current year starting Jan 01 at 00:00 [on hold]


How to determine equality for two JavaScript objects?Why would a JavaScript variable start with a dollar sign?Get the current URL with JavaScript?How do I get the current date in JavaScript?Why does the JavaScript need to start with “;”?Get current date/time in secondsGet the current year in JavaScriptGetting current date and time in JavaScriptGetting a MySQL DateTime in PHP to seconds in javascriptJavascript, counting years and days since 1970-01-01 until today













-1















I am newbee in JavaScript and i am having toughtime calculating seconds elapsed in current year not from 1970 as JavaScript default method calculates.
Basically i need to develop script which will show countup timer of products produced in current year. Question is a company produces 4 million product in a year and i need to show Counter which will show current number of items produced and keep on counting up as long as i am on this counter page. So i need number of items produced till time i have opened page and numer of milliseconds remaining in current year till 31st dec at 24:00










share|improve this question













put on hold as off-topic by Idan, Billal Begueradj, Matt Raines, Matteo Baldi, David Makogon yesterday


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Idan, Billal Begueradj, Matt Raines, Matteo Baldi
If this question can be reworded to fit the rules in the help center, please edit the question.











  • 1





    What have you tried? How was it deficient?

    – Scott Hunter
    yesterday















-1















I am newbee in JavaScript and i am having toughtime calculating seconds elapsed in current year not from 1970 as JavaScript default method calculates.
Basically i need to develop script which will show countup timer of products produced in current year. Question is a company produces 4 million product in a year and i need to show Counter which will show current number of items produced and keep on counting up as long as i am on this counter page. So i need number of items produced till time i have opened page and numer of milliseconds remaining in current year till 31st dec at 24:00










share|improve this question













put on hold as off-topic by Idan, Billal Begueradj, Matt Raines, Matteo Baldi, David Makogon yesterday


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Idan, Billal Begueradj, Matt Raines, Matteo Baldi
If this question can be reworded to fit the rules in the help center, please edit the question.











  • 1





    What have you tried? How was it deficient?

    – Scott Hunter
    yesterday













-1












-1








-1








I am newbee in JavaScript and i am having toughtime calculating seconds elapsed in current year not from 1970 as JavaScript default method calculates.
Basically i need to develop script which will show countup timer of products produced in current year. Question is a company produces 4 million product in a year and i need to show Counter which will show current number of items produced and keep on counting up as long as i am on this counter page. So i need number of items produced till time i have opened page and numer of milliseconds remaining in current year till 31st dec at 24:00










share|improve this question














I am newbee in JavaScript and i am having toughtime calculating seconds elapsed in current year not from 1970 as JavaScript default method calculates.
Basically i need to develop script which will show countup timer of products produced in current year. Question is a company produces 4 million product in a year and i need to show Counter which will show current number of items produced and keep on counting up as long as i am on this counter page. So i need number of items produced till time i have opened page and numer of milliseconds remaining in current year till 31st dec at 24:00







javascript gettime






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









Jagdish PrabhuJagdish Prabhu

1




1




put on hold as off-topic by Idan, Billal Begueradj, Matt Raines, Matteo Baldi, David Makogon yesterday


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Idan, Billal Begueradj, Matt Raines, Matteo Baldi
If this question can be reworded to fit the rules in the help center, please edit the question.







put on hold as off-topic by Idan, Billal Begueradj, Matt Raines, Matteo Baldi, David Makogon yesterday


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Idan, Billal Begueradj, Matt Raines, Matteo Baldi
If this question can be reworded to fit the rules in the help center, please edit the question.







  • 1





    What have you tried? How was it deficient?

    – Scott Hunter
    yesterday












  • 1





    What have you tried? How was it deficient?

    – Scott Hunter
    yesterday







1




1





What have you tried? How was it deficient?

– Scott Hunter
yesterday





What have you tried? How was it deficient?

– Scott Hunter
yesterday












4 Answers
4






active

oldest

votes


















1














 const first = new Date();
first.setDate(1);
first setMonth(0);
first.setHours(0);
first.setMinutes(0);

const delta = Date.now() - first;

const perMS = 4 * 10 ** 6 / (1000 * 60 * 60 * 24 * 365);

console.log(delta * perMS);





share|improve this answer






























    0














    This will give you the total number of milliseconds passed in the current year, you can then subtract it from total milliseconds in a year



    var diff = new Date(Math.abs(new Date() - new Date(new Date().getFullYear(), 0, 1))).getTime();
    console.log(diff);





    share|improve this answer























    • Thanks, i used this script and got desired result. Thanks all who replied to my question.

      – Jagdish Prabhu
      yesterday



















    0














    I have used below script, countup script is working fine, I need 'from' and 'speed' variable.



    $.fn.countTo = function(options) ;

    $.fn.countTo.defaults =
    from: 0, // the number the element should start at
    to: 100, // the number the element should end at
    speed: 1000, // how long it should take to count between the target numbers
    refreshInterval: 100, // how often the element should be updated
    decimals: 0, // the number of decimal places to show
    onUpdate: null, // callback method for every time the element is updated,
    onComplete: null, // callback method for when the element finishes updating
    ;

    var date = new Date("2019, 1, 1");
    var seconds = date.getTime() / 1000;

    var prRatePerSec = 0.12;
    var prPerYear = 4000000;
    var prProducedTill = Math.round(seconds * prRatePerSec);

    $('.timer').countTo(
    from: 0,
    to: prPerYear,
    speed: 31540000000,
    refreshInterval: 50,
    onComplete: function (value)
    console.debug(this);

    );





    share|improve this answer






























      0














      You can substract two date object with javascript.



      So substract the current date with the start year date



      Like






      var second = diffCurrentYear() / 1000;
      var day = second / 60 / 60 / 24;

      console.log(day)

      function diffCurrentYear()
      var currentYear = new Date().getFullYear(),
      diff = (new Date()).getTime() - (new Date(currentYear + '-01-01')).getTime()
      return diff;








      share|improve this answer





























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        1














         const first = new Date();
        first.setDate(1);
        first setMonth(0);
        first.setHours(0);
        first.setMinutes(0);

        const delta = Date.now() - first;

        const perMS = 4 * 10 ** 6 / (1000 * 60 * 60 * 24 * 365);

        console.log(delta * perMS);





        share|improve this answer



























          1














           const first = new Date();
          first.setDate(1);
          first setMonth(0);
          first.setHours(0);
          first.setMinutes(0);

          const delta = Date.now() - first;

          const perMS = 4 * 10 ** 6 / (1000 * 60 * 60 * 24 * 365);

          console.log(delta * perMS);





          share|improve this answer

























            1












            1








            1







             const first = new Date();
            first.setDate(1);
            first setMonth(0);
            first.setHours(0);
            first.setMinutes(0);

            const delta = Date.now() - first;

            const perMS = 4 * 10 ** 6 / (1000 * 60 * 60 * 24 * 365);

            console.log(delta * perMS);





            share|improve this answer













             const first = new Date();
            first.setDate(1);
            first setMonth(0);
            first.setHours(0);
            first.setMinutes(0);

            const delta = Date.now() - first;

            const perMS = 4 * 10 ** 6 / (1000 * 60 * 60 * 24 * 365);

            console.log(delta * perMS);






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered yesterday









            Jonas WilmsJonas Wilms

            62.7k53456




            62.7k53456























                0














                This will give you the total number of milliseconds passed in the current year, you can then subtract it from total milliseconds in a year



                var diff = new Date(Math.abs(new Date() - new Date(new Date().getFullYear(), 0, 1))).getTime();
                console.log(diff);





                share|improve this answer























                • Thanks, i used this script and got desired result. Thanks all who replied to my question.

                  – Jagdish Prabhu
                  yesterday
















                0














                This will give you the total number of milliseconds passed in the current year, you can then subtract it from total milliseconds in a year



                var diff = new Date(Math.abs(new Date() - new Date(new Date().getFullYear(), 0, 1))).getTime();
                console.log(diff);





                share|improve this answer























                • Thanks, i used this script and got desired result. Thanks all who replied to my question.

                  – Jagdish Prabhu
                  yesterday














                0












                0








                0







                This will give you the total number of milliseconds passed in the current year, you can then subtract it from total milliseconds in a year



                var diff = new Date(Math.abs(new Date() - new Date(new Date().getFullYear(), 0, 1))).getTime();
                console.log(diff);





                share|improve this answer













                This will give you the total number of milliseconds passed in the current year, you can then subtract it from total milliseconds in a year



                var diff = new Date(Math.abs(new Date() - new Date(new Date().getFullYear(), 0, 1))).getTime();
                console.log(diff);






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered yesterday









                Chaitanya BankanhalChaitanya Bankanhal

                6815




                6815












                • Thanks, i used this script and got desired result. Thanks all who replied to my question.

                  – Jagdish Prabhu
                  yesterday


















                • Thanks, i used this script and got desired result. Thanks all who replied to my question.

                  – Jagdish Prabhu
                  yesterday

















                Thanks, i used this script and got desired result. Thanks all who replied to my question.

                – Jagdish Prabhu
                yesterday






                Thanks, i used this script and got desired result. Thanks all who replied to my question.

                – Jagdish Prabhu
                yesterday












                0














                I have used below script, countup script is working fine, I need 'from' and 'speed' variable.



                $.fn.countTo = function(options) ;

                $.fn.countTo.defaults =
                from: 0, // the number the element should start at
                to: 100, // the number the element should end at
                speed: 1000, // how long it should take to count between the target numbers
                refreshInterval: 100, // how often the element should be updated
                decimals: 0, // the number of decimal places to show
                onUpdate: null, // callback method for every time the element is updated,
                onComplete: null, // callback method for when the element finishes updating
                ;

                var date = new Date("2019, 1, 1");
                var seconds = date.getTime() / 1000;

                var prRatePerSec = 0.12;
                var prPerYear = 4000000;
                var prProducedTill = Math.round(seconds * prRatePerSec);

                $('.timer').countTo(
                from: 0,
                to: prPerYear,
                speed: 31540000000,
                refreshInterval: 50,
                onComplete: function (value)
                console.debug(this);

                );





                share|improve this answer



























                  0














                  I have used below script, countup script is working fine, I need 'from' and 'speed' variable.



                  $.fn.countTo = function(options) ;

                  $.fn.countTo.defaults =
                  from: 0, // the number the element should start at
                  to: 100, // the number the element should end at
                  speed: 1000, // how long it should take to count between the target numbers
                  refreshInterval: 100, // how often the element should be updated
                  decimals: 0, // the number of decimal places to show
                  onUpdate: null, // callback method for every time the element is updated,
                  onComplete: null, // callback method for when the element finishes updating
                  ;

                  var date = new Date("2019, 1, 1");
                  var seconds = date.getTime() / 1000;

                  var prRatePerSec = 0.12;
                  var prPerYear = 4000000;
                  var prProducedTill = Math.round(seconds * prRatePerSec);

                  $('.timer').countTo(
                  from: 0,
                  to: prPerYear,
                  speed: 31540000000,
                  refreshInterval: 50,
                  onComplete: function (value)
                  console.debug(this);

                  );





                  share|improve this answer

























                    0












                    0








                    0







                    I have used below script, countup script is working fine, I need 'from' and 'speed' variable.



                    $.fn.countTo = function(options) ;

                    $.fn.countTo.defaults =
                    from: 0, // the number the element should start at
                    to: 100, // the number the element should end at
                    speed: 1000, // how long it should take to count between the target numbers
                    refreshInterval: 100, // how often the element should be updated
                    decimals: 0, // the number of decimal places to show
                    onUpdate: null, // callback method for every time the element is updated,
                    onComplete: null, // callback method for when the element finishes updating
                    ;

                    var date = new Date("2019, 1, 1");
                    var seconds = date.getTime() / 1000;

                    var prRatePerSec = 0.12;
                    var prPerYear = 4000000;
                    var prProducedTill = Math.round(seconds * prRatePerSec);

                    $('.timer').countTo(
                    from: 0,
                    to: prPerYear,
                    speed: 31540000000,
                    refreshInterval: 50,
                    onComplete: function (value)
                    console.debug(this);

                    );





                    share|improve this answer













                    I have used below script, countup script is working fine, I need 'from' and 'speed' variable.



                    $.fn.countTo = function(options) ;

                    $.fn.countTo.defaults =
                    from: 0, // the number the element should start at
                    to: 100, // the number the element should end at
                    speed: 1000, // how long it should take to count between the target numbers
                    refreshInterval: 100, // how often the element should be updated
                    decimals: 0, // the number of decimal places to show
                    onUpdate: null, // callback method for every time the element is updated,
                    onComplete: null, // callback method for when the element finishes updating
                    ;

                    var date = new Date("2019, 1, 1");
                    var seconds = date.getTime() / 1000;

                    var prRatePerSec = 0.12;
                    var prPerYear = 4000000;
                    var prProducedTill = Math.round(seconds * prRatePerSec);

                    $('.timer').countTo(
                    from: 0,
                    to: prPerYear,
                    speed: 31540000000,
                    refreshInterval: 50,
                    onComplete: function (value)
                    console.debug(this);

                    );






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered yesterday









                    Jagdish PrabhuJagdish Prabhu

                    1




                    1





















                        0














                        You can substract two date object with javascript.



                        So substract the current date with the start year date



                        Like






                        var second = diffCurrentYear() / 1000;
                        var day = second / 60 / 60 / 24;

                        console.log(day)

                        function diffCurrentYear()
                        var currentYear = new Date().getFullYear(),
                        diff = (new Date()).getTime() - (new Date(currentYear + '-01-01')).getTime()
                        return diff;








                        share|improve this answer



























                          0














                          You can substract two date object with javascript.



                          So substract the current date with the start year date



                          Like






                          var second = diffCurrentYear() / 1000;
                          var day = second / 60 / 60 / 24;

                          console.log(day)

                          function diffCurrentYear()
                          var currentYear = new Date().getFullYear(),
                          diff = (new Date()).getTime() - (new Date(currentYear + '-01-01')).getTime()
                          return diff;








                          share|improve this answer

























                            0












                            0








                            0







                            You can substract two date object with javascript.



                            So substract the current date with the start year date



                            Like






                            var second = diffCurrentYear() / 1000;
                            var day = second / 60 / 60 / 24;

                            console.log(day)

                            function diffCurrentYear()
                            var currentYear = new Date().getFullYear(),
                            diff = (new Date()).getTime() - (new Date(currentYear + '-01-01')).getTime()
                            return diff;








                            share|improve this answer













                            You can substract two date object with javascript.



                            So substract the current date with the start year date



                            Like






                            var second = diffCurrentYear() / 1000;
                            var day = second / 60 / 60 / 24;

                            console.log(day)

                            function diffCurrentYear()
                            var currentYear = new Date().getFullYear(),
                            diff = (new Date()).getTime() - (new Date(currentYear + '-01-01')).getTime()
                            return diff;








                            var second = diffCurrentYear() / 1000;
                            var day = second / 60 / 60 / 24;

                            console.log(day)

                            function diffCurrentYear()
                            var currentYear = new Date().getFullYear(),
                            diff = (new Date()).getTime() - (new Date(currentYear + '-01-01')).getTime()
                            return diff;





                            var second = diffCurrentYear() / 1000;
                            var day = second / 60 / 60 / 24;

                            console.log(day)

                            function diffCurrentYear()
                            var currentYear = new Date().getFullYear(),
                            diff = (new Date()).getTime() - (new Date(currentYear + '-01-01')).getTime()
                            return diff;






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered yesterday









                            R3tepR3tep

                            7,97682962




                            7,97682962













                                Popular posts from this blog

                                Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                                Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                                Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript