From 7f782f3b1ed08d95818747e23b0dead6079e96d4 Mon Sep 17 00:00:00 2001 From: Sangeeth Sudheer Date: Thu, 2 May 2024 14:06:18 +0530 Subject: [PATCH] Add time formatting --- time/time.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/time/time.go b/time/time.go index e94ba5a..8815d97 100644 --- a/time/time.go +++ b/time/time.go @@ -50,4 +50,21 @@ func Time() { f(now.Add(-diff)) epoch() + timeFormatting() +} + +func timeFormatting() { + now := time.Now() + t1, _ := time.Parse( + time.RFC3339, + "2023-12-25T10:00:00+05:30", + ) + f(t1) + + // Example string should match the datetime: Monday January 02 2006 15:04:05 + // (this resembles month:1 day:2 hour:3 minute:4 seconds:5 year:6) + f("Custom format:", now.Format("2006/1/2")) + f("Custom format:", now.Format("Monday, 02 Jan")) + f("Custom format:", t1.Format("Monday, _2 Jan")) + f("Custom format:", t1.Format("Monday, 2/01/2006")) }