Skip to content

Simple REST API to get time from many different timezones

Notifications You must be signed in to change notification settings

irfansofyana/go-simple-time-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Timezone API

Simple REST API for getting current time in different timezones. This is the first assignment from Rest-Based Microservices API Development in Golang Course.

Run Program

go run main.go

Example Endpoints

GET /api/time (UTC as default timezone)

Response

{
    "current_time": "2021-10-31 13:14:55.0414006 +0000 UTC"
}

GET /api/time?tz=Asia/Jakarta (Single timezone)

Response

{
    "Asia/Jakarta": "2021-10-31 20:16:26.2831456 +0700 WIB"
}

GET /api/time?tz=Asia/Jakarta,America/New_York (Multiple timezones)

Response

{
    "America/New_York": "2021-10-31 09:17:17.4514516 -0400 EDT",
    "Asia/Jakarta": "2021-10-31 20:17:17.4514159 +0700 WIB"
}

GET /api/time?tz=Asia/Bandung (Invalid timezone)

Response

{
    "error_message": "invalid timezone"
}

About

Simple REST API to get time from many different timezones

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages