// TryParseTime will try to parse input in all provided go time formats.
// Accepts: U for unix ts, UN for unix nano.
TryParseTime will try to parse input in all provided go time formats.
Accepts: U for unix ts, UN for unix nano.
// TryParseTime will try to parse input in all provided go time formats . // Accepts : U for unix ts UN for unix nano .
func TryParseTime(ts string, layouts []string, tz *time.Location) time.Time {
	const ms = 10000000000
	var (
		t   time.Time
		err error
	)
	if tz == nil {
		tz = time.UTC
	}
	for _, l := range layouts {
		if l == "U" || l == "UN" {
			var n int64
			if n, err = strconv.ParseInt(ts, 10, 64); err != nil {
				continue
			}
			if l == "U" {
				if n > ms { 
					n = n / 1000
				}
				t = time.Unix(n, 0)
			} else {
				t = time.Unix(0, n)
			}
			return t.In(tz)
		}
		if t, err = time.ParseInLocation(l, ts, tz); err == nil {
			return t
		}
	}
	return time.Time{}
}
func TryParseTime ( ts string , layouts [ ] string , tz * time . Location ) time . Time { const ms = 10000000000 var ( t time . Time err error ) if tz == nil { tz = time . UTC } for _ , l := range layouts { if l == " " || l == " " { var n int64 if n , err = strconv . ParseInt ( ts , 10 , 64 ) ; err != nil { continue } if l == " " { if n > ms { n = n / 1000 } t = time . Unix ( n , 0 ) } else { t = time . Unix ( 0 , n ) } return t . In ( tz ) } if t , err = time . ParseInLocation ( l , ts , tz ) ; err == nil { return t } } return time . Time { } }
TryParseTime will try to parse input in all provided go time formats.
TryParseTime will try to parse input in all provided go time formats .
// javascript ts in ms