This is a creation in Article, where the information may have evolved or changed.
A lot of information on the Web provides an example of how time will be converted into strings, but how the time is divided into years, months, and days respectively, for example:
, the date is displayed, and the month is shown below. As a beginner, that the information on the Internet a bit to read, record, but also look treatise.
The first thing to do is to get a variable of type time, and then use now, if you want to get it, but what about the data you read from the database? Described below:
Get system time directly
year:=time.Now().Year()month:=time.Now().Month()//time.Now().Month().String()day:=time.Now().Day()
Referencing time data in a database
month = time.Unix(dynamic.UpdateTime/10000).Month().String()day = time.Unix(dynamic.UpdateTime/10000).Day()year = time.Unix(dynamic.UpdateTime/10000).Year()
where the dynamic. UpdateTime is the time field that is read from the database, and then the month, date, and so on.
Of course, you can also add several fields (without JSON) to the structure to facilitate the display of the front end. It is important to note that year and day are all int types, and month is a string type.
In fact, this is relatively simple, but as a beginner does not know very well, hope to help.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.