{"id":28066178,"url":"https://github.com/mumuy/datex","last_synced_at":"2025-05-12T14:38:56.367Z","repository":{"id":81853431,"uuid":"576942173","full_name":"mumuy/datex","owner":"mumuy","description":"时间格式化工具 - 日期标准化/时间间隔计算/时间处理/时区切换_datetime format library","archived":false,"fork":false,"pushed_at":"2025-04-23T04:03:25.000Z","size":1291,"stargazers_count":72,"open_issues_count":0,"forks_count":12,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-12T14:38:42.600Z","etag":null,"topics":["datetime","datetime-format","datetime-library","formatter","timestamp"],"latest_commit_sha":null,"homepage":"https://passer-by.com/datex/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mumuy.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,"zenodo":null}},"created_at":"2022-12-11T13:45:57.000Z","updated_at":"2025-04-23T04:03:28.000Z","dependencies_parsed_at":"2023-10-27T04:28:12.986Z","dependency_job_id":"d21a70c6-743c-4e38-9eec-f685494f2cd4","html_url":"https://github.com/mumuy/datex","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mumuy%2Fdatex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mumuy%2Fdatex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mumuy%2Fdatex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mumuy%2Fdatex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mumuy","download_url":"https://codeload.github.com/mumuy/datex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253755920,"owners_count":21959114,"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":["datetime","datetime-format","datetime-library","formatter","timestamp"],"created_at":"2025-05-12T14:38:55.353Z","updated_at":"2025-05-12T14:38:56.324Z","avatar_url":"https://github.com/mumuy.png","language":"HTML","readme":"# Nodejs安装datex\n```js\nnpm install datex.js\n```\n# 演示网站\n\n【接口文档】[https://passer-by.com/datex/](https://passer-by.com/datex/)\n\n【世界时-中文】[https://passer-by.com/datex/timezone.html](https://passer-by.com/datex/timezone.html)\n\n【世界时-英文】[https://thedate.today/](https://thedate.today/)\n\n# datex方法说明\n\n## getTime() 返回时间戳(毫秒)\n```js\ndatex().getTime()\n// =\u003e 1670768193313\n```\n\n## getUnix() 返回时间戳(秒)\n```js\ndatex().getUnix()\n// =\u003e 1670768193\n```\n\n## clone() 返回克隆对象\n```js\ndatex().clone()\n```\n\n## toDate() 返回原生Date对象\n```js\ndatex().toDate()\n// =\u003e Sun Dec 11 2022 22:20:20 GMT+0800 (中国标准时间)\n```\n\n## toObject() 返回时间字段对象\n```js\ndatex().toDate()\n// =\u003e {\n\tyear:2022,\n\tmonth:12,\n\tday:11,\n\thour:22,\n\tminute:23,\n\tsecond: 14,\n\tmillsecond:612,\n\ttimestamp:1670768594612,\n\tweek:0\n}\n```\n\n## toArray() 返回时间字段数值\n```js\ndatex().toArray()\n// =\u003e [2022,12,11,22,23,14,612]\n```\n\n## toString() 返回字符串\n```js\ndatex().toDate()\n// =\u003e Sun Dec 11 2022 22:20:20 GMT+0800 (中国标准时间)\n```\n\n## toISOString() 返回ISO字符串\n```js\ndatex().toDate()\n// =\u003e 2023-04-12T07:20:23.363Z\n```\n\n## format(pattern) 返回格式化时间\n```js\ndatex(2022,10,1).format('YYYY-MM-DD HH:mm:ss')\n// =\u003e 2022-10-01 00:00:00\n\ndatex(1671761818503).format('YYYY/MM/DD')\n// =\u003e 2022/12/23\n```\n\n## set(name,value) 设置某字段值\n```js\ndatex(2022,10,1).set('year',2020).format()\n// =\u003e 2020-10-01 00:00:00\n```\n\n## change(name,value) 增减某字段值\n```js\ndatex(2022,10,1).change('year',1).format()\n// =\u003e 2022-10-01 00:00:00\n```\n\n## startOf(name) 获取某字段起始时\n```js\ndatex(2022,10,10).startOf('month').format()\n// =\u003e 2022-10-01 00:00:00\n```\n\n## endOf(name) 获取某字段末尾时\n```js\ndatex(2022,10,10).endOf('month').format()\n// =\u003e 2022-10-31 23:59:59\n```\n\n## get(name) 返回某字段值\n```js\ndatex(2022,10,1).get('year')\n// =\u003e 2022\n```\n\n## diffWith(dateStr|datex,name) 返回某字段差值\n```js\ndatex('1949-10-01').diffWith('2022-12-01','month')\n// =\u003e -878\n```\n\n## isBefore(dateStr|datex,name) 是否在某个时间点之前\n```js\ndatex('2008-08-08').isBefore('2022-02-02')\n// =\u003e true\n```\n\n## isAfter(dateStr|datex,name) 是否在某个时间点之后\n```js\ndatex('2008-08-08').isAfter('2022-02-02')\n// =\u003e false\n```\n\n## isSame(dateStr|datex,name) 是否和某个时间点相等\n```js\ndatex('2008-08-08').isSame('2022-02-02')\n// =\u003e false\n```\n\n## isBetween(dateStr|datex,dateStr|datex,name) 是否在两个时间点之间\n```js\ndatex('2008-08-08').isBetween('2003-07-13','2022-02-02')\n// =\u003e true\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmumuy%2Fdatex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmumuy%2Fdatex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmumuy%2Fdatex/lists"}