{"id":149,"date":"2017-07-27T15:35:38","date_gmt":"2017-07-27T15:35:38","guid":{"rendered":"http:\/\/robinplomp.com\/?p=149"},"modified":"2017-07-27T15:35:38","modified_gmt":"2017-07-27T15:35:38","slug":"change-the-date-to-the-epoch-format","status":"publish","type":"post","link":"https:\/\/robinplomp.com\/?p=149","title":{"rendered":"Change the date to the EPOCH format"},"content":{"rendered":"<p>For a recent project it is a requirement to change a date value to the EPOCH format. We need this EPOCH date format to automate the creation of a ticket in a Remedy system. The customer is using BMC Atrium Orchestration as a frontend to the Remedy system.<\/p>\n<p><em><strong>What is EPOCH Time?<\/strong><br \/>The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since <b>January 1, 1970<\/b> (midnight UTC\/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).<\/em><\/p>\n<p><em><strong>Why does EPOCH time start in 1970?<br \/><\/strong>So no file can be created before 1970-01-01. &#8230; Unix was originally developed in the 60s and 70s so the &#8220;start&#8221; of Unix Time was set to January 1st 1970 at midnight GMT (Greenwich Mean Time) &#8211; this date\/time was assigned the Unix Time value of 0. This is what is know as the Unix Epoch.<\/em><\/p>\n<p>I\u2019ve created a small PowerShell function to convert a Get-Date input to the EPOCH date\/time format.<\/p>\n<pre class=\"brush: csharp; auto-links: true; collapse: false; first-line: 1; gutter: true; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;\">function ConvertTo-Epoch ([datetime]$InputEpoch) {\n    [datetime]$Epoch = '1970-01-01 00:00:00'\n    [int]$Ctime = \"\"\n\n    $Ctime = (New-TimeSpan -Start $Epoch -End $InputEpoch).TotalSeconds\n    return $Ctime\n}\n\n$a = ConvertTo-Epoch (get-date)\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>For a recent project it is a requirement to change a date value to the EPOCH format. We need this EPOCH date format to automate the creation of a ticket in a Remedy system. The customer is using BMC Atrium Orchestration as a frontend to the Remedy system. What is EPOCH Time?The Unix epoch (or &hellip; <a href=\"https:\/\/robinplomp.com\/?p=149\" class=\"more-link\">Lees verder <span class=\"screen-reader-text\">Change the date to the EPOCH format<\/span> <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":[14],"tags":[11],"class_list":["post-149","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-powershell"],"_links":{"self":[{"href":"https:\/\/robinplomp.com\/index.php?rest_route=\/wp\/v2\/posts\/149","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/robinplomp.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robinplomp.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robinplomp.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robinplomp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=149"}],"version-history":[{"count":1,"href":"https:\/\/robinplomp.com\/index.php?rest_route=\/wp\/v2\/posts\/149\/revisions"}],"predecessor-version":[{"id":150,"href":"https:\/\/robinplomp.com\/index.php?rest_route=\/wp\/v2\/posts\/149\/revisions\/150"}],"wp:attachment":[{"href":"https:\/\/robinplomp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=149"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robinplomp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=149"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robinplomp.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=149"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}