Every line of 'golang get current time' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.
188 func GetCurrentTime() int64 { 189 return time.Now().Unix() 190 }
1145 func GetCurrentTime(result *C.GTimeVal) { 1146 C.g_get_current_time(result) 1147 }
120 func (ko *LkkOS) Uptime() (uint64, error) { 121 boot, err := bootTime() 122 if err != nil { 123 return 0, err 124 } 125 126 res := uint64(time.Now().Unix()) - boot 127 return res, nil 128 }
96 func GetCurrentTimeUnix() string { 97 t := time.Now() 98 return fmt.Sprintf("%v", t.Unix()) 99 }
75 func BootTime() (uint64, error) { 76 t := atomic.LoadUint64(&cachedBootTime) 77 if t != 0 { 78 return t, nil 79 } 80 values, err := common.DoSysctrl("kern.boottime") 81 if err != nil { 82 return 0, err 83 } 84 // ex: { sec = 1392261637, usec = 627534 } Thu Feb 13 12:20:37 2014 85 v := strings.Replace(values[2], ",", "", 1) 86 87 boottime, err := strconv.ParseUint(v, 10, 64) 88 if err != nil { 89 return 0, err 90 } 91 t = uint64(boottime) 92 atomic.StoreUint64(&cachedBootTime, t) 93 94 return t, nil 95 }
140 func getCurrentUnixTimestamp() int64 { 141 now := time.Now() 142 secs := now.Unix() 143 return secs 144 }
14 func get() (time.Duration, error) { 15 out, err := unix.SysctlRaw("kern.boottime") 16 if err != nil { 17 return time.Duration(0), err 18 } 19 var timeval syscall.Timeval 20 if len(out) != int(unsafe.Sizeof(timeval)) { 21 return time.Duration(0), fmt.Errorf("unexpected output of sysctl kern.boottime: %v (len: %d)", out, len(out)) 22 } 23 timeval = *(*syscall.Timeval)(unsafe.Pointer(&out[0])) 24 sec, nsec := timeval.Unix() 25 return time.Now().Sub(time.Unix(sec, nsec)), nil 26 }
1152 func (s *Delete_commandContext) Time() ITimeContext { 1153 var t = s.GetTypedRuleContext(reflect.TypeOf((*ITimeContext)(nil)).Elem(), 0) 1154 1155 if t == nil { 1156 return nil 1157 } 1158 1159 return t.(ITimeContext) 1160 }
198 func getCurrentNanoTime() int64 { 199 return time.Now().UnixNano() 200 }
99 func getRunningTime(handle windows.Handle) (time.Duration, error) { 100 var creationTime, exitTime, kernelTime, userTime windows.Filetime 101 err := windows.GetProcessTimes(handle, &creationTime, &exitTime, &kernelTime, &userTime) 102 if err != nil { 103 return 0, err 104 } 105 createdAt := time.Unix(0, creationTime.Nanoseconds()) 106 return time.Since(createdAt), nil 107 }