jokes-bapak2/api/app/v1/utils/date.go

17 lines
322 B
Go

package utils
import "time"
// IsToday checks if a date is in fact today or not.
func IsToday(date string) (bool, error) {
parse, err := time.Parse(time.RFC3339, date)
if err != nil {
return false, err
}
y1, m1, d1 := parse.Date()
y2, m2, d2 := time.Now().Date()
return y1 == y2 && m1 == m2 && d1 == d2, nil
}