> For the complete documentation index, see [llms.txt](https://rafli-ramadhan.gitbook.io/golang-example-code-by-topic/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rafli-ramadhan.gitbook.io/golang-example-code-by-topic/package/time/time-since.md).

# Time Since

Time since merupakan fungsi untuk memperoleh durasi waktu dari sejak fungsi time.Now() di inisiasi ke suatu variabel.

## Contoh *code* time since dengan time sleep detik

```go
package main

import (
	"fmt"
	"time"
)

func main() {
	start := time.Now()
	// fmt.Println(start)
	time.Sleep(1 * time.Second)
	fmt.Println(time.Since(start))
	fmt.Println(time.Since(start).Nanoseconds())
	fmt.Println(time.Since(start).Microseconds())
	fmt.Println(time.Since(start).Milliseconds())
	fmt.Println(time.Since(start).Seconds())
	fmt.Println(time.Since(start).Minutes())
	fmt.Println(time.Since(start).Hours())
}

```

```
5.0137703s
5015350700
5016250
5017
5.0179141
0.08365447166666666
0.0013947766666666667
```

## Contoh *code* time since dengan time sleep menit

```go
package main

import (
	"fmt"
	"time"
)

func main() {
	start := time.Now()
	time.Sleep(1 * time.Minute)
	fmt.Println(time.Since(start))
	fmt.Println(time.Since(start).Nanoseconds())
	fmt.Println(time.Since(start).Microseconds())
	fmt.Println(time.Since(start).Milliseconds())
	fmt.Println(time.Since(start).Seconds())
	fmt.Println(time.Since(start).Minutes())
	fmt.Println(time.Since(start).Hours())
}

```

```
1m0.0130677s
60013966400
60014645
60015
60.0157221
1.0002705466666666
0.016671274333333333
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rafli-ramadhan.gitbook.io/golang-example-code-by-topic/package/time/time-since.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
