Add time formatting

This commit is contained in:
Sangeeth Sudheer 2024-05-02 14:06:18 +05:30
parent b6550b9032
commit 7f782f3b1e
Signed by: x
GPG Key ID: F6D06ECE734C57D1
1 changed files with 17 additions and 0 deletions

View File

@ -50,4 +50,21 @@ func Time() {
f(now.Add(-diff)) f(now.Add(-diff))
epoch() 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"))
} }