Intuitive time manipulation for Go - Making date/time operations as simple as they should be.
GoTime extends Go's standard time
package with human-friendly operations that developers actually need in real-world applications. It leverages Go's powerful time handling while providing an intuitive API that makes working with dates and times a breeze.
import "github.com/maniartech/gotime"
// Intuitive formatting - no more "2006-01-02"!
formatted := gotime.Format(time.Now(), "yyyy-mm-dd hh:ii:ss")
// β "2025-07-07 14:30:45"
// Easy format conversion
converted, _ := gotime.Convert("07/07/2025", "mm/dd/yyyy", "mmmm dt, yyyy")
// β "July 7th, 2025"
// Human-readable relative time
timeAgo := gotime.TimeAgo(time.Now().Add(-5 * time.Minute))
// β "5 minutes ago"
// Simple date arithmetic
nextBusinessDay := gotime.WorkDay(1, time.Now())
tenDaysFromNow := gotime.Days(10, time.Now())
The Problem: Go's time formatting is cryptic and error-prone
// Standard Go - Who remembers this?
time.Now().Format("2006-01-02 15:04:05") // π΅βπ«
The Solution: Human-readable format specifiers
// GoTime - Intuitive and memorable
gotime.Format(time.Now(), "yyyy-mm-dd hh:ii:ss") // π
What You Get | Standard Go | GoTime |
---|---|---|
Natural Syntax | Cryptic 2006-01-02 |
NITES yyyy-mm-dd |
Relative Time | 15+ lines of code | TimeAgo() |
Format Conversion | Parse + Format | Convert() |
Date Arithmetic | Complex calculations | WorkDay() , Days() |
Business Logic | Manual calculations | Built-in helpers |
- Web APIs - Consistent date formatting across endpoints
- Reports - Human-readable timestamps and date ranges
- Business Logic - Working day calculations, relative dates
- Data Processing - Converting between date formats
- User Interfaces - "2 hours ago" style timestamps
go get github.com/maniartech/gotime
Requirements: Go 1.13+ β’ Zero dependencies β’ TinyGo compatible*
// Remember yyyy-mm-dd, not 2006-01-02
formatted := gotime.Format(time.Now(), "mmmm dt, yyyy")
// β "July 7th, 2025"
date, _ := gotime.Parse("2025-07-07", "yyyy-mm-dd")
date, _ := gotime.Parse("07/07/2025", "mm/dd/yyyy")
iso, _ := gotime.Convert("07/07/2025", "mm/dd/yyyy", "yyyy-mm-dd")
// β "2025-07-07"
gotime.TimeAgo(fiveMinutesAgo) // β "5 minutes ago"
gotime.TimeAgo(nextWeek) // β "Next week"
nextBusinessDay := gotime.WorkDay(1, time.Now())
businessDaysCount := gotime.NetWorkDays(startDate, endDate)
- 5-Minute Quick Start - Get productive immediately
- Why GoTime? - Detailed comparison with standard library
- NITES Format Specifiers - Complete NITES reference
- API Reference - All functions with examples
- Real-World Examples - Web APIs, databases, business logic
- Web Development - APIs, user timestamps
- Database Integration - Custom types, queries
- Business Applications - Invoices, schedules
- Analytics - Time-series, monitoring
100% Test Coverage β Every function is thoroughly tested
250+ Automated Test Cases β Industry-grade reliability
- β Production Ready β Used in real-world applications
- β Zero Dependencies β Only uses Go standard library
- β TinyGo Compatible β Works in embedded and WebAssembly*
- β MIT Licensed β Free for commercial use
GoTime's core library is designed to be compatible with TinyGo for use in embedded and WebAssembly environments. Test helpers and some internal utilities use reflect
and runtime
and are not TinyGo compatible, but these are not required for end users. To build with TinyGo, you must use a Go version supported by TinyGo (currently Go 1.19β1.22). See examples/tinygo/main.go
for a working example.
Contributions are welcome! Please ensure your code includes tests and follows existing patterns.
Found an issue? Open an issue Want to contribute? See our contribution guidelines
MIT Licensed - see LICENSE for details.