Derek Neely

...notes for thyself, but useful for all...

Golang Date Formatting


Aug 30, 2017 by derek

For anyone using or getting their feet wet wtih Golang, they'll quickly notice that the Date/Time formatting in Go is, well, a bit different than most other languages. Unfortunately you can't use the good ole 'Y-m-d H:i:s" which is familiar and makes sense.

We found this very helpful resource of a nice table provided by: Martynas @ medium.com.

1609-09-12 19:02:35 PM +03:00 Sep Sat PDT 
--------------- + ------------ + ------------ 
Type            | Placeholder  | Value 
--------------- + ------------ + ------------ 
Year            | 2006         | 1609         
Year            | 06           | 09           
Month           | 01           | 09           
Month           | 1            | 9            
Month           | Jan          | Sep          
Month           | January      | September    
Day             | 02           | 12           
Day             | 2            | 12           
Week day        | Mon          | Sat          
Week day        | Monday       | Saturday     
Hours           | 03           | 07           
Hours           | 3            | 7            
Hours           | 15           | 19           
Minutes         | 04           | 02           
Minutes         | 4            | 2            
Seconds         | 05           | 35           
Seconds         | 5            | 35           
AM or PM        | PM           | PM           
Milliseconds     | .000         | .123         
Microseconds    | .000000      | .123456      
Nanoseconds     | .000000000   | .123456789   
Timezone offset | -0700        | +0300        
Timezone offset | -07:00       | +03:00       
Timezone offset | Z0700        | +0300        
Timezone offset | Z07:00       | +03:00       
Timezone        | MST          | PDT          
--------------- + ------------ + ------------

 

Golang

Social


Tweet Tweet Tweet


© 2016 Derek Neely