{"id":13412459,"url":"https://github.com/deatil/go-datebin","last_synced_at":"2025-03-23T10:34:38.405Z","repository":{"id":39251069,"uuid":"477228145","full_name":"deatil/go-datebin","owner":"deatil","description":" A date and time parse and format library for Go.","archived":false,"fork":false,"pushed_at":"2024-12-04T02:50:06.000Z","size":165,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-18T19:54:36.083Z","etag":null,"topics":["date","datebin","datetime","go","go-datebin","time"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/deatil/go-datebin","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deatil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-03T03:28:01.000Z","updated_at":"2024-12-04T02:43:04.000Z","dependencies_parsed_at":"2023-01-27T14:01:22.346Z","dependency_job_id":"8003a92a-b75c-4099-a2e2-1bb31b96b0b4","html_url":"https://github.com/deatil/go-datebin","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deatil%2Fgo-datebin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deatil%2Fgo-datebin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deatil%2Fgo-datebin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deatil%2Fgo-datebin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deatil","download_url":"https://codeload.github.com/deatil/go-datebin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245090886,"owners_count":20559296,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["date","datebin","datetime","go","go-datebin","time"],"created_at":"2024-07-30T20:01:24.923Z","updated_at":"2025-03-23T10:34:38.137Z","avatar_url":"https://github.com/deatil.png","language":"Go","funding_links":[],"categories":["日期和时间","Date and Time"],"sub_categories":["检索及分析资料库","Search and Analytic Databases"],"readme":"## go-datebin\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://pkg.go.dev/github.com/deatil/go-datebin\"\u003e\u003cimg src=\"https://pkg.go.dev/badge/deatil/go-datebin.svg\" alt=\"Go Reference\"\u003e\u003c/a\u003e\n\u003ca href=\"https://codecov.io/gh/deatil/go-datebin\" \u003e\n \u003cimg src=\"https://codecov.io/gh/deatil/go-datebin/graph/badge.svg?token=SS2Z1IY0XL\"/\u003e\n\u003c/a\u003e\n\u003cimg src=\"https://goreportcard.com/badge/github.com/deatil/go-datebin\" /\u003e\n\u003ca href=\"https://github.com/avelino/awesome-go\"\u003e\u003cimg src=\"https://awesome.re/mentioned-badge.svg\" alt=\"Mentioned in Awesome Go\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\n### Desc\n\n*  go-datebin is a simple datetime parse pkg.\n\n[中文](README_CN.md) | English\n\n\n### Download\n\n~~~go\ngo get -u github.com/deatil/go-datebin\n~~~\n\n\n### Get Starting\n\n~~~go\npackage main\n\nimport (\n    \"fmt\"\n\n    \"github.com/deatil/go-datebin/datebin\"\n)\n\nfunc main() {\n    // now time\n    date := datebin.\n        Now().\n        ToDatetimeString()\n    // output: 2024-01-06 12:06:12\n\n    // Parse date and have no timezone\n    date2 := datebin.\n        Parse(\"2032-03-15 12:06:17\").\n        ToDatetimeString(datebin.UTC)\n    // output: 2032-03-15 12:06:17\n\n    // Parse date and have timezone\n    date2 := datebin.\n        ParseWithLayout(\"2032-03-15 12:06:17\", datebin.DatetimeFormat, datebin.GMT).\n        ToDatetimeString()\n    // output: 2032-03-15 12:06:17\n\n    // set time and format output\n    date3 := datebin.\n        FromDatetime(2032, 3, 15, 12, 56, 5).\n        ToFormatString(\"Y/m/d H:i:s\")\n    // output: 2032/03/15 12:56:05\n}\n\n~~~\n\n\n### Examples\n\n~~~go\n// format timestamp\nvar datetimeString string = datebin.FromTimestamp(1705329727, datebin.Shanghai).ToDatetimeString()\n// output: 2024-01-15 22:42:07\n\n// format timestamp with timezone\nvar datetimeString string = datebin.FromTimestamp(1705329727).ToDatetimeString(datebin.Shanghai)\n// output: 2024-01-15 22:42:07\n~~~\n\n~~~go\n// get now timestamp\nvar timestamp int64 = datebin.Now().Timestamp()\n// output: 1705329727\n~~~\n\n~~~go\n// get now time\nvar timestamp int64 = datebin.Now(datebin.Iran).ToRFC1123String()\n// output: Sun, 21 Jan 2024 07:48:22 +0330\n~~~\n\n~~~go\n// get now stdtime\nvar stdTime time.Time = datebin.Now().ToStdTime()\n// fmt.Sprintf(\"%s\", stdTime) output: 2024-01-15 23:55:03.0770405 +0800 CST\n\n// get now stdtime with timezone\nvar stdTime time.Time = datebin.Now(datebin.UTC).ToStdTime()\n// fmt.Sprintf(\"%s\", stdTime) output: 2024-01-19 01:59:11.8134897 +0000 UTC\n~~~\n\n~~~go\n// format stdtime\nvar datetimeString string = datebin.FromStdTime(stdTime).ToDatetimeString()\n// output: 2024-01-15 23:55:03\n~~~\n\n~~~go\n// format datetime\nvar datetimeString string = datebin.FromDatetime(2024, 01, 15, 23, 35, 01).ToDatetimeString()\n// output: 2024-01-15 23:35:01\n~~~\n\nmore docs and see [docs](docs.md)\n\n\n### LICENSE\n\n*  The library LICENSE is `Apache2`, using the library need keep the LICENSE.\n\n\n### Copyright\n\n*  Copyright deatil(https://github.com/deatil).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeatil%2Fgo-datebin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeatil%2Fgo-datebin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeatil%2Fgo-datebin/lists"}