This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package DateUtil
import "time"
/**
功能:获取当前的时间字符串
作者:黄海
时间:2020-01-20
*/
func GetCurrentTimeStr() string {
return time.Now().Format("20060102150405")
}
const TimeLayoutStr = "2006-01-02 15:04:05" //go中的时间格式化必须是这个时间
功能:将一个字符串转为对应的时间
作者:黄海
时间:2020-05-29
func ConvertDateTime(ts string) time.Time {
st, _ := time.Parse(TimeLayoutStr, ts) //string转time
return st
func ConvertDate(ts string) time.Time {
return ConvertDateTime(ts + " 00:00:00")