{"id":6963,"date":"2014-03-26T05:02:51","date_gmt":"2014-03-25T18:02:51","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=6963"},"modified":"2014-03-26T05:02:51","modified_gmt":"2014-03-25T18:02:51","slug":"phpjavascripthtml-datetime-period-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/phpjavascripthtml-datetime-period-primer-tutorial\/","title":{"rendered":"PHP\/Javascript\/HTML DateTime Period Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/DateDiff\/\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"PHP\/Javascript\/HTML DateTime Period Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/DateDiff\/PHP_DateDiff.jpg\" title=\"PHP\/Javascript\/HTML DateTime Period Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">PHP\/Javascript\/HTML DateTime Period Primer Tutorial<\/p><\/div>\n<p>Today&#8217;s tutorial shows some PHP and Javascript functionality building on a Yahoo Answers <a target=_blank title='Yahoo Answers PHP timestamp question ... thanks' href='http:\/\/au.answers.yahoo.com\/question\/index?qid=20140323132912AAvhq2z'>question<\/a> asking about date (difference) functionality using PHP.<\/p>\n<p>There always appear to be lots of functionality in computer languages to do with dates and times, and that is because humans like to know <i>&#8220;when&#8221;<\/i> something happened, and because computer languages normally allow for data types to do with Date and, as for this tutorial, DateTime.  This division of data types may seem a bit over the top, but quite often in programming, the time component of a DateTime is actually a pest, and we&#8217;d much rather deal with a Date object &#8230; not so today.<\/p>\n<p>As you code and deal with dates it is good to have sanity checks ready, with websites like <a target=_blank title='Independent date checking helper' href='http:\/\/www.day-calculator.com\/'>Day of the week calendar checker<\/a> that can make sure your calls have the same understanding as your computer language about concepts like 0 represents Sunday, 1 represents Monday, or that 0 represents January, 1 represents February etcetera, etcetera (ie. sometimes the way we computer types like to start counting at 0 is not always (but is usually) how the software gets designed &#8230; you should always try to independently sanity check such crucial issues).   Of course, you should try to understand the PHP by looking up the excellent syntax instructions and examples at the <a target=_blank title='Home of PHP' href='http:\/\/php.net'>home of PHP<\/a>.<\/p>\n<p>Other funny thing about website date processing is that when you have an interaction with the user you will have to rely on Javascript to keep you right regarding the workings of date related input data.   We haven&#8217;t catered for every potential bad user input here, in this tutorial (something for you to improve on), and that is why Javascript libraries such as YUI and jQuery have good calendar interfaces, which also have the advantage of looking better.<\/p>\n<p>Thinking about the power of YUI and jQuery libraries makes the job easier, but what this tutorial can help with, is logic and methods to do with date and\/or time differences.<\/p>\n<p>Thanks for the tutorial content inspiration go to <a target=_blank title='Famous Dates and Times in History' href='http:\/\/blog.onlineclock.net\/famous-dates-times\/'>Famous Dates and Times in History<\/a>.   Obviously, the choices of what is important historically is very subjective, and you may want to tailor your own set of dates and times (this is a hard-coded section of the HTML code as downloadable below.<\/p>\n<p>Other useful tutorials (thanks) helping were:<\/p>\n<ul>\n<li><a target=_blank title='PHP: DateTime::diff - Manual' href='http:\/\/php.net\/manual\/en\/datetime.diff.php'>PHP: DateTime::diff &#8211; Manual<\/a><\/li>\n<li><a target=_blank title='How to get current date in JavaScript - Stack Overflow' href='http:\/\/stackoverflow.com\/questions\/1531093\/how-to-get-current-date-in-javascript\/'>How to get current date in JavaScript &#8211; Stack Overflow<\/a><\/li>\n<li><a target=_blank title='How do you convert a JavaScript date to UTC? - Stack Overflow' href='http:\/\/stackoverflow.com\/questions\/948532\/how-do-you-convert-a-javascript-date-to-utc'>How do you convert a JavaScript date to UTC? &#8211; Stack Overflow<\/a><\/li>\n<\/ul>\n<p>Here is a link to some downloadable HTML (with Javascript) programming code you could rename to <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/DateDiff\/dtdiff.html_GETME\" title=\"dtdiff.html\">dtdiff.html<\/a> supervising the downloadable PHP  code you could rename to <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/DateDiff\/dtdiff.php_GETME\" title=\"dtdiff.php\">dtdiff.php<\/a> (called as an iframe within a table).<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d6963' onclick='var dv=document.getElementById(\"d6963\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=PHP\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d6963' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Today&#8217;s tutorial shows some PHP and Javascript functionality building on a Yahoo Answers question asking about date (difference) functionality using PHP. There always appear to be lots of functionality in computer languages to do with dates and times, and that &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/phpjavascripthtml-datetime-period-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,37],"tags":[301,302,576,652,932,997,1279,1319],"class_list":["post-6963","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","tag-date","tag-datetime","tag-html","tag-javascript","tag-php","tag-programming","tag-time","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/6963"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=6963"}],"version-history":[{"count":0,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/6963\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=6963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=6963"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=6963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}