https://github.com/zitudu/go-ms
Use this package to easily convert various time formats to milliseconds. This is a Go port of the Javascript ms library.
https://github.com/zitudu/go-ms
duration go go-ms golang milliseconds ms ms-go time
Last synced: 5 months ago
JSON representation
Use this package to easily convert various time formats to milliseconds. This is a Go port of the Javascript ms library.
- Host: GitHub
- URL: https://github.com/zitudu/go-ms
- Owner: zitudu
- License: mit
- Created: 2020-10-11T06:07:46.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-04-02T08:04:44.000Z (about 3 years ago)
- Last Synced: 2024-06-20T01:51:01.714Z (almost 2 years ago)
- Topics: duration, go, go-ms, golang, milliseconds, ms, ms-go, time
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-ms
[](https://pkg.go.dev/github.com/zitudu/go-ms)
[](https://goreportcard.com/report/github.com/zitudu/go-ms)
Use this package to easily convert various time formats to milliseconds. This is a Go port of [the Javascript ms library](https://github.com/vercel/ms).
## Install
Requires Go 1.11 and above. Run this command
go get github.com/zitudu/go-ms
## Usage
```go
import "github.com/zitudu/go-ms"
age, err := ms.Parse("30days") // 2592000000.000000
expiresIn := ms.MustParse("20 hrs") // 72000000.000000
ms.FormatShort(60000) // 1m
ms.FormatLong(-3 * 60000) // -3 minutes
```
## License
MIT