How to Print Specific date-time in Golang? Last Updated : 17 May, 2020 Comments Improve Suggest changes Like Article Like Report Golang supports time formatting and parsing via pattern-based layouts. In Go, the current time can be determined by using time.Now(), provided by the time package. Package time provides functionality for measuring and displaying the time. To print Current date-time you need to import the "time" package in your Go program to work with date and time. Example: C // Golang program to show // the use of time.Now() Function package main import "fmt" import "time" func main() { dt := time.Now() // printing the time in string format fmt.Println("Current date and time is: ", dt.String()) } Output : Current date and time is: 2020-05-05 06:43:01.419199824 +0000 UTC m=+0.000076701 To print Specific date-time in Golang use format constants provided in the time package. The commonly used formats are: const ( ANSIC = "Mon Jan _2 15:04:05 2006" UnixDate = "Mon Jan _2 15:04:05 MST 2006" RubyDate = "Mon Jan 02 15:04:05 -0700 2006" RFC822 = "02 Jan 06 15:04 MST" RFC822Z = "02 Jan 06 15:04 -0700" // RFC822 with numeric zone RFC850 = "Monday, 02-Jan-06 15:04:05 MST" RFC1123 = "Mon, 02 Jan 2006 15:04:05 MST" RFC1123Z = "Mon, 02 Jan 2006 15:04:05 -0700" // RFC1123 with numeric zone RFC3339 = "2006-01-02T15:04:05Z07:00" RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00" Kitchen = "3:04PM" // Handy time stamps. Stamp = "Jan _2 15:04:05" StampMilli = "Jan _2 15:04:05.000" StampMicro = "Jan _2 15:04:05.000000" StampNano = "Jan _2 15:04:05.000000000" ) Example: C // Golang program to print specific date and time package main import "fmt" import "time" func main() { dt := time.Now() // printing date and time in UnixDate format fmt.Println("Specific date and time is: ", dt.Format(time.UnixDate)) } Output: Specific date and time is: Tue May 5 07:05:00 UTC 2020 Example: C // Golang program to print specific date and time package main import "fmt" import "time" func main() { dt := time.Now() // Format MM-DD-YYYY fmt.Println(dt.Format("01-02-2006")) // Format MM-DD-YYYY hh:mm:ss fmt.Println(dt.Format("01-02-2006 15:04:05")) // With short weekday (Mon) fmt.Println(dt.Format("01-02-2006 15:04:05 Mon")) // With weekday (Monday) fmt.Println(dt.Format("01-02-2006 15:04:05 Monday")) // Include micro seconds fmt.Println(dt.Format("01-02-2006 15:04:05.000000")) } Output: 11-10-2009 11-10-2009 23:00:00 11-10-2009 23:00:00 Tue 11-10-2009 23:00:00 Tuesday 11-10-2009 23:00:00.000000 Comment More infoAdvertise with us Next Article How to Print Specific date-time in Golang? A ankit_12r23 Follow Improve Article Tags : Go Language GoLang-time Golang-Program Similar Reads How to Get the String in Specified Base in Golang? Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides a FormatInt() function which is used to return the string representation of x in the given base, i.e., 2 <= base <= 36. Here, the resul 2 min read How to compare times in Golang? With the help of Before() and After() and Equal(), function we can compare the time as well as date but we are also going to use the time.Now() and time.Now().Add() function for comparison. Functions Used: These functions compares the times as seconds. Before(temp) - This function is used to check i 2 min read How to Trim a String in Golang? In Go, strings are UTF-8 encoded sequences of variable-width characters, unlike some other languages like Java, python and C++. Go provides several functions within the strings package to trim characters from strings.In this article we will learn how to Trim a String in Golang.Examples := "@@Hello, 2 min read How to separate date and time in R ? In this article, we are going to separate date and time in R Programming Language.  Date-time is in the format of date and time (YYYY/MM/DD HH:MM:SS- year/month/day Hours:Minute:Seconds). Extracting date from timestamp: We are going to extract date by using as.Date() function. Syntax:  as.Date(data 2 min read How to Get Current time in Golang? With the help of time.Now() function, we can get the current time in Golang by importing time module. Syntax: time.Now() Return: Return current date and time. Example #1: In this example, we can see that by using time.Now() function, we are able to get the current date and time. C // Golang program 1 min read How to Format date using strftime() in Python ? In this article, we will see how to format date using strftime() in Python. localtime() and gmtime() returns a tuple representing a time and this tuple is converted into a string as specified by the format argument using python time method strftime(). Syntax: time.strftime(format[, sec]) sec: This i 2 min read How to Check File Size and Last Modified Time in Golang? In the Go language, the os module provides the ability to access native operating-system features. In the os package, the Stat() function is used to check the file size and last modified time. This method gives the FileInfo structure describing the file and an error of type *PathError. // FileInfo d 2 min read Parsing Time in Golang Parsing time is to convert our time to Golang time object so that we can extract information such as date, month, etc from it easily. We can parse any time by using time.Parse function which takes our time string and format in which our string is written as input and if there is no error in our form 2 min read How to Get Current Date and Time in Various Format in Golang? Package "time" in Golang provides functionality for measuring and displaying time. The calendrical calculations always assume a Gregorian calendar, with no leap seconds. Using the "time.Now()" function you can get the date and time in the "yyyy-mm-dd hh:mm:ss.milliseconds timezone" format. This is s 3 min read time.Parse() Function in Golang With Examples In Go language, time packages supplies functionality for determining as well as viewing time. The Parse() function in Go language is used to parse a formatted string and then finds the time value that it forms. Moreover, this function is defined under the time package. Here, you need to import "time 2 min read Like