{"id":691,"date":"2004-11-11T10:01:16","date_gmt":"2004-11-11T10:01:16","guid":{"rendered":"http:\/\/beta.robertprice.co.uk\/robblog\/2004\/11\/the_current_uk_population_in_javascript-shtml\/"},"modified":"2004-11-11T10:01:16","modified_gmt":"2004-11-11T10:01:16","slug":"the_current_uk_population_in_javascript-shtml","status":"publish","type":"post","link":"https:\/\/www.robertprice.co.uk\/robblog\/the_current_uk_population_in_javascript-shtml\/","title":{"rendered":"The Current UK Population In JavaScript"},"content":{"rendered":"<p>\nOne interesting webpage going round the office yesterday were the <a href=\"http:\/\/www.statistics.gov.uk\/cci\/nugget.asp?id=950\">UK Population Statistics<\/a>.\n<\/p>\n<p>\nLooking at the figures for 2002-2003 we saw the total UK population grow from 59,321,700 people to 59,553,800 people.\n<\/p>\n<p>\nThat means the population grows by approximately 1 person every 2 and a half minutes.\n<\/p>\n<p>\nI&#8217;ve knocked together a quick JavaScript that can calculate the approximate population of the UK assuming this increase is constant.\n<\/p>\n<p>\nWe work out the per minute increase in population. We also know the starting population of the UK on the 1st January 2003, all we have to do is work out how minutes have elapsed between then and now, and multiply that by the population growth per minute.\n<\/p>\n<div class=\"code\"><code>var startDate = new Date(\"January 1, 2003 00:00:00\");<br \/>\nvar perMinuteIncrease = 232100 \/ (365 * 24 * 60);<br \/>\nvar startPop = 59553800;<br \/>\n\/\/ return the estimated current population of the UK.<br \/>\nfunction currentPopulation() {<br \/>\nvar currentDate = new Date();<br \/>\nvar diffMinutes = Math.floor((currentDate.getTime() - startDate.getTime()) \/ 60000);<br \/>\nreturn Math.round(startPop + (diffMinutes * perMinuteIncrease));<br \/>\n}<br \/>\n<\/code><\/div>\n<p>\nTo get the current population you just call the <code>currentPopulation()<\/code> function.\n<\/p>\n<p>\nLet&#8217;s see what the approximate current UK population is now according to this script&#8230;\n<\/p>\n<div>\n<!-- Ideally this should be in the head of the document and just called --><br \/>\n<script language=\"JavaScript\" type=\"text\/javascript\">\n<!--\nvar startDate = new Date(\"January 1, 2003 00:00:00\");\nvar perMinuteIncrease = 232100 \/ (365 * 24 * 60);\nvar startPop = 59553800;\n\/\/ return the estimated current population of the UK.\nfunction currentPopulation() {\nvar currentDate = new Date();\nvar diffMinutes = Math.floor((currentDate.getTime() - startDate.getTime()) \/ 60000);\nreturn Math.round(startPop + (diffMinutes * perMinuteIncrease));\n}\ndocument.write(\"The current UK population is approximately <em>\" + currentPopulation() + \"<\/em> people\");\n\/\/ -->\n<\/script><br \/>\n<noscript><br \/>\nSorry! You need to enable JavaScript to see the current UK population.<br \/>\n<\/noscript>\n<\/div>\n<p>\nJust reload\/refresh the page to get an updated population count.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One interesting webpage going round the office yesterday were the UK Population Statistics. Looking at the figures for 2002-2003 we saw the total UK population grow from 59,321,700 people to 59,553,800 people. That means the population grows by approximately 1 person every 2 and a half minutes. I&#8217;ve knocked together a quick JavaScript that can &hellip; <a href=\"https:\/\/www.robertprice.co.uk\/robblog\/the_current_uk_population_in_javascript-shtml\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;The Current UK Population In JavaScript&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[2],"tags":[17,75],"class_list":["post-691","post","type-post","status-publish","format-standard","hentry","category-dev","tag-dev","tag-web-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>The Current UK Population In JavaScript - Robert Price<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.robertprice.co.uk\/robblog\/the_current_uk_population_in_javascript-shtml\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The Current UK Population In JavaScript - Robert Price\" \/>\n<meta property=\"og:description\" content=\"One interesting webpage going round the office yesterday were the UK Population Statistics. Looking at the figures for 2002-2003 we saw the total UK population grow from 59,321,700 people to 59,553,800 people. That means the population grows by approximately 1 person every 2 and a half minutes. I&#8217;ve knocked together a quick JavaScript that can &hellip; Continue reading &quot;The Current UK Population In JavaScript&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.robertprice.co.uk\/robblog\/the_current_uk_population_in_javascript-shtml\/\" \/>\n<meta property=\"og:site_name\" content=\"Robert Price\" \/>\n<meta property=\"article:published_time\" content=\"2004-11-11T10:01:16+00:00\" \/>\n<meta name=\"author\" content=\"rob\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rob\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/the_current_uk_population_in_javascript-shtml\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/the_current_uk_population_in_javascript-shtml\\\/\"},\"author\":{\"name\":\"rob\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\"},\"headline\":\"The Current UK Population In JavaScript\",\"datePublished\":\"2004-11-11T10:01:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/the_current_uk_population_in_javascript-shtml\\\/\"},\"wordCount\":165,\"keywords\":[\"Dev\",\"Web Development\"],\"articleSection\":[\"Dev\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/the_current_uk_population_in_javascript-shtml\\\/\",\"url\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/the_current_uk_population_in_javascript-shtml\\\/\",\"name\":\"The Current UK Population In JavaScript - Robert Price\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#website\"},\"datePublished\":\"2004-11-11T10:01:16+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/the_current_uk_population_in_javascript-shtml\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/the_current_uk_population_in_javascript-shtml\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/the_current_uk_population_in_javascript-shtml\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The Current UK Population In JavaScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#website\",\"url\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/\",\"name\":\"Robert Price\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\",\"name\":\"rob\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"caption\":\"rob\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The Current UK Population In JavaScript - Robert Price","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.robertprice.co.uk\/robblog\/the_current_uk_population_in_javascript-shtml\/","og_locale":"en_GB","og_type":"article","og_title":"The Current UK Population In JavaScript - Robert Price","og_description":"One interesting webpage going round the office yesterday were the UK Population Statistics. Looking at the figures for 2002-2003 we saw the total UK population grow from 59,321,700 people to 59,553,800 people. That means the population grows by approximately 1 person every 2 and a half minutes. I&#8217;ve knocked together a quick JavaScript that can &hellip; Continue reading \"The Current UK Population In JavaScript\"","og_url":"https:\/\/www.robertprice.co.uk\/robblog\/the_current_uk_population_in_javascript-shtml\/","og_site_name":"Robert Price","article_published_time":"2004-11-11T10:01:16+00:00","author":"rob","twitter_card":"summary_large_image","twitter_misc":{"Written by":"rob","Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.robertprice.co.uk\/robblog\/the_current_uk_population_in_javascript-shtml\/#article","isPartOf":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/the_current_uk_population_in_javascript-shtml\/"},"author":{"name":"rob","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5"},"headline":"The Current UK Population In JavaScript","datePublished":"2004-11-11T10:01:16+00:00","mainEntityOfPage":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/the_current_uk_population_in_javascript-shtml\/"},"wordCount":165,"keywords":["Dev","Web Development"],"articleSection":["Dev"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/www.robertprice.co.uk\/robblog\/the_current_uk_population_in_javascript-shtml\/","url":"https:\/\/www.robertprice.co.uk\/robblog\/the_current_uk_population_in_javascript-shtml\/","name":"The Current UK Population In JavaScript - Robert Price","isPartOf":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/#website"},"datePublished":"2004-11-11T10:01:16+00:00","author":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5"},"breadcrumb":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/the_current_uk_population_in_javascript-shtml\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.robertprice.co.uk\/robblog\/the_current_uk_population_in_javascript-shtml\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.robertprice.co.uk\/robblog\/the_current_uk_population_in_javascript-shtml\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.robertprice.co.uk\/robblog\/"},{"@type":"ListItem","position":2,"name":"The Current UK Population In JavaScript"}]},{"@type":"WebSite","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#website","url":"https:\/\/www.robertprice.co.uk\/robblog\/","name":"Robert Price","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.robertprice.co.uk\/robblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5","name":"rob","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","caption":"rob"}}]}},"_links":{"self":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/691","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/comments?post=691"}],"version-history":[{"count":0,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/691\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/media?parent=691"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/categories?post=691"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/tags?post=691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}