How to get the first few days of the current time in golang

silencement
Release: 2019-12-25 13:13:14
Original
5785 people have browsed it

How to get the first few days of the current time in golang

Get the current time

currentTime := time.Now()
//currentTime 的结果为go的时间time类型,2018-09-27 13:24:58.287714118 +0000 UTC
Copy after login

Get the time of the previous n days

//获取两天前的时间
currentTime := time.Now()
oldTime := currentTime.AddDate(0, 0, -2)		//若要获取3天前的时间,则应将-2改为-3
//oldTime 的结果为go的时间time类型,2018-09-25 13:24:58.287714118 +0000 UTC
Copy after login

It is recommended to study "golang tutorial".

The above is the detailed content of How to get the first few days of the current time in golang. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template