Can someone explain how the milliseconds works and some documentation. I am trying to work out, given two dates, what is the years, days and months difference between the two dates. Ideally I would want to round off the number so no decimals. Is this possible in JavaScript without any libraries?  This is my code so far. I have tried doing 1000 * 60 / 365 and a few combinations but I do not know what those represent - I may try hours too.          var date1 = new Date(a); // 01/03/2008         var date2 = new Date(b); // 22/03/2016         var timeDiff = Math.abs(date2.getTime() - date1.getTime());         var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));          var diffMonths = Math.ceil(timeDiff / (12));          var diffYears = Math.ceil(timeDiff / (365));          console.log(diffDays);         console.log(diffMonths);         console.log(diffYears);   I managed to work out days difference but I still do not understand it fully.
I'm creating an application which lets you define events with a time frame.  I want to automatically fill in the end date when the user selects or changes the start date.  I can't quite figure out, however, how to get the difference between the two times, and then how to create a new end Date using that difference.
How to find all subgroups of a direct product? I am wondering how do we find all subgroups of a direct product? Is there a method to find it?  For example, how can we find all the subgroups of $\mathbb{Z}_2\times\mathbb{Z}_2$?  There is the answer: $\{(0, 0), (1, 0)\}, \{(0, 0), (0, 1)\}, \{(0, 0), (1, 1)\}$, and the improper and trivial subgroup. But I do not know the method how to find it.   All I can think about is the following: since the order of $\mathbb{Z}_2\times\mathbb{Z}_2$ is $4$, the order of a subgroup of it can be $1,2$ or $4$.   If order is $1$, then it is trivial, and if order is $4$, it is proper. Then, the order of a subgroup is $2$. We know all the elements of   $\mathbb{Z}_2\times\mathbb{Z}_2$, so we try all the pairs.   Is that the method?   But what if we are given a bigger order product, such as $\mathbb{Z}_2\times\mathbb{Z}_8\times\mathbb{Z}_3\times\mathbb{Z}_9$? It looks very long to try all possibilities.   Can anyone help?  Thanks Prove a graph Containing $2k$ odd vertices contains $k$ distinct trails "I let him do it" and "I allow him to do it", why exactly does one require 'to'? Orthogonal projections with $\sum P_i =I$, proving that $i\ne j \Rightarrow  P_{j}P_{i}=0$ Value of momentum of a particle in 1D box prepared in a particular state? What is the value of momentum of particle in 1D box in state $\sin(10\pi x/a)$? My understanding Standing waves representing particle in 1D box is not an momentum eigenstate so if we measure the momentum of particle in this state we may get any value of momentum which gives a distribution whose expectation value tends to zero. Answer key In the answer key it's given that the value of momentum is 5h/a and -5h/a.If we measure the momentum for this state we may get any of these two values.But is this a wrong reasoning because if these was the case,these should mean that 5h/a and -5h/a are the eigenvalue of the following wavefunction which is clearly not. What is the correct answer? How to make GRASS and SAGA tools capable to use in QGIS？ I installed QGIS, GRASS and GDAL by OSGeo4w package, and as I finish the installation, I want to use GRASS tool, I face this problem：    But I already installed GRASS and SAGA, how to make those tools in QGIS to be used？ This formula provides the $n$th term in the Fibonacci Sequence, and is defined using the recurrence formula: $u_n = u_{n − 1} + u_{n − 2}$, for $n &gt; 1$,  where $u_0 = 0$ and $u_1 = 1$.   Show that     $$u_n = \frac{(1 + \sqrt{5})^n - (1 - \sqrt{5})^n}{2^n \sqrt{5}}.$$    Please help me with its proof. Thank you. Add sort by relevance to search jobs In Careers 2.0, individuals can choose "search jobs" and sort by date posted, job title, and company name.  However, Careers 2.0 already knows what tags I'm proficient in, and knows the tags associated with the job postings.  A sort option, relevance, should be added so that jobs matching my skill set, as demonstrated on stack exchange, will float to the top. What ubuntu applications provide support? (guides, how to's, status) Also, specifically, details on support for syncing music to iPhone's and iPod's with the latest OS version:   Can you sync music to apple devices using >iOS4? (iPhone &amp; iPod) What applications allow you to do this and how? (guides, how to's, status)    What has already been established is:   Apple does not support Linux and has no plans to.  provides some support, however it currently does not support music/video synchronization with devices &gt;iOS4. Go to  and scroll to the section titled "" to see if your device version is supported. I run sudo apt-get install git-all in Ubuntu 16.04 and see the following in the end  Setting up runit (2.1.2-3ubuntu1) ... start: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused dpkg: error processing package runit (--configure):  subprocess installed post-installation script returned error exit status 1 dpkg: dependency problems prevent configuration of git-daemon-run:  git-daemon-run depends on runit; however:   Package runit is not configured yet.  dpkg: error processing package git-daemon-run (--configure):  dependency problems - leaving unconfigured No apport report written because the error message indicates its a followup error from a previous failure.                       Errors were encountered while processing:  runit  git-daemon-run E: Sub-process /usr/bin/dpkg returned an error code (1)   I get the error after rebooting my system also. It really blocks my whole system.  I run killall update-notifier. I run sudo apt-get install git-all but  I get the same error message. I run pgrep -a apt but get nothing as output. I run pgrep -a update but get nothing as output.  A bug report about the case .    In Grub, Choose Advanced options > Ubuntu (Upstart) Linux kernel 4.22. Doing the same only in terminal without systemd causes the same error.      Why is this error here with runit? Trying to Remember a Book that explored evolution of Dinosaurs to intelligence and then encountering humans Many, many years ago, I read a book where dinosaurs were assumed to have suvived the K-T event (or it never happened), and they evolved to intelligent species that used not only language (which combined sound, posture, and colour changes on their skin) but also used technology.  In the series, a human is captured or somehow gets integrated with one of the evolved dinosaur groups.  Again, from a very faint memory, the dinosaurs had a level of technology that would be about middle ages, and the humans were much more analogous to American Indian.  That's really all I can recall about the book, and I am trying to find it for my daughter to read.  Can anyone help me out? Python Argument Binders How can I bind arguments to a Python method to store a nullary functor for later invocation?  Similar to C++'s boost::bind.  For example:  def add(x, y):     return x + y  add_5 = magic_function(add, 5) assert add_5(3) == 8 Was Elrond, in Tolkien's opinion, more inherently powerful than Galadriel? I always thought it was the other way around, but then I read this (Letter 246):     "Of the others only Gandalf might be expected to master him – being an emissary of the Powers and a creature of the same order, an immortal spirit taking a visible physical form. In the 'Mirror of Galadriel', 1381, it appears that Galadriel conceived of herself as capable of wielding the Ring and supplanting the Dark Lord. If so, so also were the other guardians of the Three, especially Elrond. But this is another matter. It was part of the essential deceit of the Ring to fill minds with imaginations of supreme power."   This "especially Elrond" confuses me. I don´t think that Elrond is inherently more powerful than Galadriel, who is described as the greatest of the Noldor, except for Fëanor (and possibly even his equal).  A quote from Unfinished Tales says:     "...In this he (Tolkien) emphasized the commanding stature of   Galadriel already in Valinor, the equal if unlike endowments of   Fëanor; and it is said here that so far from joining in Fëanor's   revolt she was in every way opposed to him."   Furthermore,      "A queen she was of the woodland Elves, the wife of Celeborn of   Doriath, yet she herself was of the Noldor and remember the Day before   days in Valinor, and she was the mightiest and fairest (so even   fairer than Arwen I would guess) of all the Elves that remained in   Middle-earth."   (The Silmarillion, of the Rings of Power)  And again...     "Galadriel was the greatest of the Noldor, except Fëanor maybe, though   she was wiser than he, and her wisdom increased with the long years."   (the Shibboleth of Fëanor)  Restating it:     "These two kinsfolk (Fëanor and Galadriel), the greatest of the   Eldar in Valinor, were unfriends for ever." "Who together with the   greatest of all the Eldar, Luthien Tinuviel, daughter of Elu Thingol,   are the chief matter of the legends and histories of the Elves."   (Unfinished Tales)  The latter means that Luthien, Fëanor and Galadriel are the chief matter of the history and legends. It seems to me that Tolkien thought of those three as the creme de la creme of the elven crop.  Reading all that I have serious problems believing that Elrond could be superior to her. As great as Elrond is, descending from Melian, he is no equal of Fëanor, who is said to be the mightiest of all elves, and if Galadriel is his equal, then there is no way that Elrond would be mightier than her.  Maybe I just read this "especially Elrond" wrong; it could as well mean that especially Elrond was deceived into thinking that he could master the ring, because that was the deceit of the ring. And Tolkien said explicitly that only Gandalf could possibly master it.  So, what do you think? Upgrade from MaaS 2.6.2 to MaaS 2.7 Book with a girl whose grandma is a phoenix, cover depicts the emerald/green-eyed blonde girl I read this book in 2016, but I remember the cover being torn up, so it couldn't have been a new book. There was a girl's face on the cover. She had lightly colored skin, and beautiful emerald green eyes. Her hair was a dirty blond. This book was first in a trilogy and the cover was illustrated.  The girl's grandmother in the story was actually a phoenix (I think this was revealed in a different book in the trilogy though). The book started out in a small village, and I can't remember exactly where in the village chapters (the chapters that took place in the village) but she sneaked her deceased mother's green dress out of a trunk she wasn't supposed to go in, and I think she wore it to some event. Speeding up a NOT IN subquery Good evening,  I'm currently up to try to improve the performance of some of my queries. As far as I know, statements like "IN" or "NOT IN" are even faster with a large amount of values if a subquery on an indexed field without conditions is used.  SELECT * FROM table1 WHERE field1 NOT IN (SELECT index_field FROM table2)   When it comes to use conditions at table2, the query becomes realy slow on a large amount of data.  SELECT * FROM table1 WHERE     field1 NOT IN (         SELECT             index_field         FROM table2         WHERE             user_id = '2'     )   I was thinking about using LEFT Join but when I need to to the filtering for the user_id, it also becomes slow.  How may I solve this problem? Currently, I've no clue about that.  The original query looked sth. like this  SELECT     i.* FROM stream_item si LEFT JOIN user__publisher_item ui     ON ui.user_id = 2     &amp;&amp; ui.item_id = si.item_id INNER JOIN item i     ON i.id = si.item_id WHERE      si.stream_id IN (5,7,8,9,19,24,29,42,43,44)     &amp;&amp; ui.id IS NULL || (         ui.`read` = 0 || ui.saved = 1     ) GROUP BY     si.item_id ORDER BY     si.`found` DESC LIMIT 0,10     id      select_type     table   type        possible_keys                                                                           key                 key_len     ref                 rows        Extra 1       SIMPLE          si      index       PRIMARY,stream_2_item,stream_id_found                                                   stream_2_item       4           \N                  663236      Using temporary; Using filesort 1       SIMPLE          ui      eq_ref      user_id_item_id,user_2_item,user_id_read_saved_hidden,user_id_saved,user_id_hidden      user_id_item_id     8           const,si.item_id    1           Using where 1       SIMPLE          i       eq_ref      PRIMARY                                                                                 PRIMARY             4           si.item_id          1      I have a table which represents the n:m relationship between stream and items. An unique item can be accessible via multiple streams. Based upon this i have a state-table for user dependent states of an item. Currently, the user-state-entry will only be generated, if the item was read or saved the first tim. Otherwise, there is no entry in the user_item table. In the beginning, this query was fine but now, it takes a lot of time. Even if I leave out the "INNER JOIN" it takes 7 seconds on the current tables with around 500k rows each.  The table-structure in the background is as follows:   stream stream_item //n:m relation between stream and items item //unique items stream_group //user-defined groups of multiple streams stream_group_streams //_n:m relation between stream_groups and streams_ user user_item //state-table that holds the user-dependent states of an item - if there is no state, no row exists for an item   I already asked this question at  but added my 2 Edits with further information to late so that I haven't got an answer anymore. Are Playstation 4 games locked to a certain region? This question has been asked before, but it was for PS3 and Xbox 360 and was asked August 2010. This time around my question goes specifically to PS4, since I'm moving from Mexico to Europe and I was wondering if the European games will run in my console or if I'll have to buy a new one. I never thought of this before (which is why I never paid attention if it was mentioned in reports or specs of the console) and the research I did wasn't too helpful. Practice problem for exam:     Let ${A_n}$ satisfy $\sum\limits_{n=1}^\infty P(A_n \cap A^c_{n+1}) &lt; \infty$ and $\lim\limits_{n\to \infty} P(A_n) = 0$.  Show that $P(\lim \sup A_n) = 0$.    I can see that it is sufficient to show that $P\left(\sum\limits_{n=1}^\infty A_n\right) &lt; \infty$ and then apply the Borel-Cantelli lemma, but I am having trouble showing this from the information given.  I see an almost identical problem here: , however the hint there is not enough for me to make headway, and this problem is also different in which term gets the complement inside the first sum. "compare with" or "compare to" Please check both sentences and let me know, which one is correct and why?   She compares me with her boyfriend.  She compares me to her boyfriend. I use  on Windows 7 and I want to know if there is a good substitution for it on Ubuntu.   I want something that is good for editing html files.