{"id":4070,"date":"2014-10-08T07:55:51","date_gmt":"2014-10-08T11:55:51","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=4070"},"modified":"2014-10-08T07:59:50","modified_gmt":"2014-10-08T11:59:50","slug":"powershell-dates-times-and-formats","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4070\/powershell-dates-times-and-formats\/","title":{"rendered":"PowerShell Dates, Times and Formats"},"content":{"rendered":"<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/astroclock_thumb.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-4071\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/astroclock_thumb.png\" alt=\"astroclock_thumb\" width=\"150\" height=\"105\" \/><\/a>If you are like me you use date time values constantly in PowerShell. From simply displaying the current date and time in progress message to using different values to create file or folder names. The Get-Date cmdlet has a -Format parameter which you can use. The tricky part is remembering what values to specify. Especially because they are case-sensitive. The values are documented at <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.globalization.datetimeformatinfo%28VS.85%29.aspx\" target=\"_blank\">http:\/\/msdn.microsoft.com\/en-us\/library\/system.globalization.datetimeformatinfo%28VS.85%29.aspx.<\/a><\/p>\n<p>So to make my life (and maybe yours) easier, I wrote a little PowerShell script to remind me of the possible values.<\/p>\n<pre class=\"lang:ps decode:true \" >$patterns = \"d\",\"D\",\"g\",\"G\",\"f\",\"F\",\"m\",\"o\",\"r\",\"s\", \"t\",\"T\",\"u\",\"U\",\"Y\",\"dd\",\"MM\",\"yyyy\",\"yy\",\"hh\",\"mm\",\"ss\",\"yyyyMMdd\",\"yyyyMMddhhmm\",\"yyyyMMddhhmmss\"\r\n\r\nWrite-host \"It is now $(Get-Date)\" -ForegroundColor Green\r\n\r\nforeach ($pattern in $patterns) {\r\n#display text\r\n\"{0}`t{1}\" -f $pattern,(Get-Date -Format $pattern)\r\n\r\n} #foreach\r\n\r\nWrite-Host \"Most patterns are case sensitive\" -ForegroundColor Green<\/pre>\n<p>The variable $patterns is an array of commonly used datetime format values. Many of them were pulled from that MSDN page but I added some of my own at the end. Here's the output from this script.<br \/>\n<a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern01.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern01-1024x795.png\" alt=\"test-datetimepattern01\" width=\"474\" height=\"367\" class=\"aligncenter size-large wp-image-4072\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern01-1024x795.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern01-300x233.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern01.png 1179w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><\/a><\/p>\n<p>This looks nice, and is definitely a nice cheat sheet. But then I realized since I'm writing a script I should take this to the next level and write a useful object to the pipeline.<\/p>\n<pre class=\"lang:ps decode:true \" >$patterns = \"d\",\"D\",\"g\",\"G\",\"f\",\"F\",\"m\",\"o\",\"r\",\"s\", \"t\",\"T\",\"u\",\"U\",\"Y\",\"dd\",\"MM\",\"yyyy\",\"yy\",\"hh\",\"mm\",\"ss\",\"yyyyMMdd\",\"yyyyMMddhhmm\",\"yyyyMMddhhmmss\"\r\n\r\nWrite-host \"It is now $(Get-Date)\" -ForegroundColor Green\r\n\r\nforeach ($pattern in $patterns) {\r\n\r\n#create an Object\r\n[pscustomobject]@{\r\n Pattern = $pattern\r\n Syntax = \"Get-Date -format '$pattern'\"\r\n Value = (Get-Date -Format $pattern)\r\n}\r\n\r\n} #foreach\r\n\r\nWrite-Host \"Most patterns are case sensitive\" -ForegroundColor Green<\/pre>\n<p>This version creates a custom object for each pattern, including the syntax.<br \/>\n<a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern02.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern02-1024x575.png\" alt=\"test-datetimepattern02\" width=\"474\" height=\"266\" class=\"aligncenter size-large wp-image-4073\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern02-1024x575.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern02-300x168.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern02.png 1752w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><\/a><\/p>\n<p>An alternative to -Format is to use the ToStringMethod() specifying the format pattern.<\/p>\n<pre class=\"lang:batch decode:true \" >PS C:\\&gt; (get-date).ToString('o')\r\n2014-10-08T07:58:46.0376740-04:00<\/pre>\n<p>Because this is an object I can pipe it to other cmdlets.<\/p>\n<pre class=\"lang:ps decode:true \" >C:\\scripts\\Test-DatePattern.ps1 | format-table<\/pre>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern03.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern03-1024x575.png\" alt=\"test-datetimepattern03\" width=\"474\" height=\"266\" class=\"aligncenter size-large wp-image-4074\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern03-1024x575.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern03-300x168.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern03.png 1752w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><\/a><\/p>\n<p>I included the syntax so all you need to do is copy and paste. Or, how about this? <\/p>\n<pre class=\"lang:ps decode:true \" >Function Insert-Pattern {\r\nC:\\scripts\\Test-DatePattern.ps1 | Out-GridView -Title \"Select a format\" -OutputMode Single |\r\nforeach {\r\n  $psise.CurrentFile.Editor.InsertText($_.Syntax)\r\n}\r\n}<\/pre>\n<p>Define this function in the PowerShell ISE, perhaps even adding it to your Add-Ons menu with a keyboard shortcut. When executed, you'll get a graphical display using Out-Gridview.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern04.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern04-1024x528.png\" alt=\"test-datetimepattern04\" width=\"474\" height=\"244\" class=\"aligncenter size-large wp-image-4076\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern04-1024x528.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern04-300x154.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/test-datetimepattern04.png 1536w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><\/a><\/p>\n<p>Select a pattern and the syntax gets pasted into your PowerShell script. I love making PowerShell do my work for me! Enjoy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are like me you use date time values constantly in PowerShell. From simply displaying the current date and time in progress message to using different values to create file or folder names. The Get-Date cmdlet has a -Format parameter which you can use. The tricky part is remembering what values to specify. Especially&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"New from the blog: #PowerShell Dates, Times and Formats","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,8],"tags":[70,534,540],"class_list":["post-4070","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-datetime","tag-powershell","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PowerShell Dates, Times and Formats &#8226; The Lonely Administrator<\/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:\/\/jdhitsolutions.com\/blog\/powershell\/4070\/powershell-dates-times-and-formats\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PowerShell Dates, Times and Formats &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"If you are like me you use date time values constantly in PowerShell. From simply displaying the current date and time in progress message to using different values to create file or folder names. The Get-Date cmdlet has a -Format parameter which you can use. The tricky part is remembering what values to specify. Especially...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/4070\/powershell-dates-times-and-formats\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2014-10-08T11:55:51+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-10-08T11:59:50+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/astroclock_thumb.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4070\\\/powershell-dates-times-and-formats\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4070\\\/powershell-dates-times-and-formats\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"PowerShell Dates, Times and Formats\",\"datePublished\":\"2014-10-08T11:55:51+00:00\",\"dateModified\":\"2014-10-08T11:59:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4070\\\/powershell-dates-times-and-formats\\\/\"},\"wordCount\":282,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4070\\\/powershell-dates-times-and-formats\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/10\\\/astroclock_thumb.png\",\"keywords\":[\"DateTime\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4070\\\/powershell-dates-times-and-formats\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4070\\\/powershell-dates-times-and-formats\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4070\\\/powershell-dates-times-and-formats\\\/\",\"name\":\"PowerShell Dates, Times and Formats &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4070\\\/powershell-dates-times-and-formats\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4070\\\/powershell-dates-times-and-formats\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/10\\\/astroclock_thumb.png\",\"datePublished\":\"2014-10-08T11:55:51+00:00\",\"dateModified\":\"2014-10-08T11:59:50+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4070\\\/powershell-dates-times-and-formats\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4070\\\/powershell-dates-times-and-formats\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4070\\\/powershell-dates-times-and-formats\\\/#primaryimage\",\"url\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/10\\\/astroclock_thumb.png\",\"contentUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/10\\\/astroclock_thumb.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4070\\\/powershell-dates-times-and-formats\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PowerShell Dates, Times and Formats\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PowerShell Dates, Times and Formats &#8226; The Lonely Administrator","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:\/\/jdhitsolutions.com\/blog\/powershell\/4070\/powershell-dates-times-and-formats\/","og_locale":"en_US","og_type":"article","og_title":"PowerShell Dates, Times and Formats &#8226; The Lonely Administrator","og_description":"If you are like me you use date time values constantly in PowerShell. From simply displaying the current date and time in progress message to using different values to create file or folder names. The Get-Date cmdlet has a -Format parameter which you can use. The tricky part is remembering what values to specify. Especially...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4070\/powershell-dates-times-and-formats\/","og_site_name":"The Lonely Administrator","article_published_time":"2014-10-08T11:55:51+00:00","article_modified_time":"2014-10-08T11:59:50+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/astroclock_thumb.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4070\/powershell-dates-times-and-formats\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4070\/powershell-dates-times-and-formats\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"PowerShell Dates, Times and Formats","datePublished":"2014-10-08T11:55:51+00:00","dateModified":"2014-10-08T11:59:50+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4070\/powershell-dates-times-and-formats\/"},"wordCount":282,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4070\/powershell-dates-times-and-formats\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/astroclock_thumb.png","keywords":["DateTime","PowerShell","Scripting"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4070\/powershell-dates-times-and-formats\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4070\/powershell-dates-times-and-formats\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4070\/powershell-dates-times-and-formats\/","name":"PowerShell Dates, Times and Formats &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4070\/powershell-dates-times-and-formats\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4070\/powershell-dates-times-and-formats\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/astroclock_thumb.png","datePublished":"2014-10-08T11:55:51+00:00","dateModified":"2014-10-08T11:59:50+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4070\/powershell-dates-times-and-formats\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4070\/powershell-dates-times-and-formats\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4070\/powershell-dates-times-and-formats\/#primaryimage","url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/astroclock_thumb.png","contentUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/astroclock_thumb.png"},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4070\/powershell-dates-times-and-formats\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"PowerShell Dates, Times and Formats"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":2193,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2193\/powershell-scripting-with-validatescript\/","url_meta":{"origin":4070,"position":0},"title":"PowerShell Scripting with [ValidateScript]","author":"Jeffery Hicks","date":"April 12, 2012","format":false,"excerpt":"The last few days we've been looking at parameter validation attributes you might use in a script of function. Yesterday I wrote about [ValidateRange] and demonstrated how you might use it. That attribute works fine for any values that can be evaluated as numbers. But dates are a different story.\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2247,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2247\/powershell-scripting-with-validatecount\/","url_meta":{"origin":4070,"position":1},"title":"PowerShell Scripting with [ValidateCount]","author":"Jeffery Hicks","date":"April 26, 2012","format":false,"excerpt":"Here's another parameter validation attribute you might want to use in your PowerShell scripting and functions. If your parameter can take an array of values, you might want to limit that array to a certain size. For example, your parameter can take an array of computer names but you don't\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/validatecount-ok-300x66.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2206,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2206\/powershell-scripting-with-validateset\/","url_meta":{"origin":4070,"position":2},"title":"PowerShell Scripting with [ValidateSet]","author":"Jeffery Hicks","date":"April 16, 2012","format":false,"excerpt":"Today we'll continue our exploration of the parameter validation attributes you can use in you PowerShell scripting. We've already looked at [ValidateRange] and [ValidateScript]. Another attribute you are likely to use is [ValidateSet()]. You can use this to verify that the parameter value belongs to a pre-defined set. To use,\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2188,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2188\/powershell-scripting-with-validaterange\/","url_meta":{"origin":4070,"position":3},"title":"PowerShell Scripting with [ValidateRange]","author":"Jeffery Hicks","date":"April 11, 2012","format":false,"excerpt":"After my post yesterday on using the ValidateScript attribute with PSCredentials, I thought you might find it helpful to have a brief discussion on some other parameter validation attributes such as [ValidateRange()]. You can use this attribute if you want to verify that a given parameter value falls between some\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1143,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1143\/set-file-encoding\/","url_meta":{"origin":4070,"position":4},"title":"Set File Encoding","author":"Jeffery Hicks","date":"February 15, 2011","format":false,"excerpt":"For most people, when you create a script in PowerShell you generally don't worry too much about how it is encoded. Most everything you encounter in PowerShell uses Unicode files. But when sharing files sometimes this causes problems. For example, when I post a script for download here, I need\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2306,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2306\/powershell-scripting-with-validatenotnullorempty\/","url_meta":{"origin":4070,"position":5},"title":"PowerShell Scripting with [ValidateNotNullorEmpty]","author":"Jeffery Hicks","date":"May 15, 2012","format":false,"excerpt":"I've been writing about the different parameter validation attributes that you can use in your PowerShell scripting. One that I use in practically every script is [ValidateNotNullorEmpty()]. This validation will ensure that something is passed as a parameter value. I'm not talking about making a parameter mandatory; only that if\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/05\/validatenotnullorempty-300x141.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4070","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=4070"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4070\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=4070"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=4070"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=4070"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}