From b22c8fbd27f91b662c742bd439b6751329c770f4 Mon Sep 17 00:00:00 2001 From: berkayalan Date: Tue, 3 Sep 2024 15:20:11 +0200 Subject: [PATCH] date basics added --- basics/main.go | 8 ++++++-- basics/time/date_and_time.go | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 basics/time/date_and_time.go diff --git a/basics/main.go b/basics/main.go index 0c9cef2..e5f028d 100644 --- a/basics/main.go +++ b/basics/main.go @@ -1,6 +1,8 @@ package main -import "basics/defers" +import ( + timebasics "basics/time" +) func main() { @@ -57,7 +59,7 @@ func main() { // defers.DeferUsage() // defers.SendPanic() // defers.OutofBound() - defers.RecoverPanic() + // defers.RecoverPanic() //error_handling.OpenFile() //error_handling.GetNumber() @@ -67,6 +69,8 @@ func main() { //strings.CreateString() //strings.StringAdvanced() + timebasics.CallNow() + } func VariablesFunction() { diff --git a/basics/time/date_and_time.go b/basics/time/date_and_time.go new file mode 100644 index 0000000..c0f12b5 --- /dev/null +++ b/basics/time/date_and_time.go @@ -0,0 +1,16 @@ +package timebasics + +import ( + "fmt" + "time" +) + +func CallNow() { + fmt.Println("Now Function: ", time.Now()) + fmt.Println("Now Function's converted to UTC: ", time.Now().UTC()) + fmt.Println("Now Function's weekday ", time.Now().Weekday()) + fmt.Println("Now Function's year: ", time.Now().Year()) + fmt.Println("Now Function's day: ", time.Now().Day()) + fmt.Println("Now Function's hour: ", time.Now().Hour()) + +}