{"id":13408270,"url":"https://github.com/felixge/node-dateformat","last_synced_at":"2025-05-14T00:04:48.098Z","repository":{"id":386185,"uuid":"1474943","full_name":"felixge/node-dateformat","owner":"felixge","description":"A node.js package for Steven Levithan's excellent dateFormat() function.","archived":false,"fork":false,"pushed_at":"2023-03-31T14:05:02.000Z","size":896,"stargazers_count":1295,"open_issues_count":15,"forks_count":156,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-05-03T00:44:06.168Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/felixge.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2011-03-13T16:27:09.000Z","updated_at":"2025-04-14T00:20:47.000Z","dependencies_parsed_at":"2023-07-05T14:45:01.367Z","dependency_job_id":null,"html_url":"https://github.com/felixge/node-dateformat","commit_stats":{"total_commits":210,"total_committers":39,"mean_commits":5.384615384615385,"dds":0.4571428571428572,"last_synced_commit":"c53e475891130a1fecd3b0d9bc5ebf3820b31b44"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixge%2Fnode-dateformat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixge%2Fnode-dateformat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixge%2Fnode-dateformat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixge%2Fnode-dateformat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felixge","download_url":"https://codeload.github.com/felixge/node-dateformat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254036923,"owners_count":22003694,"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":[],"created_at":"2024-07-30T20:00:51.791Z","updated_at":"2025-05-14T00:04:48.060Z","avatar_url":"https://github.com/felixge.png","language":"JavaScript","readme":"# dateformat\n\nA node.js package for Steven Levithan's excellent [dateFormat()][dateformat] function.\n\n## Modifications\n\n- Removed the `Date.prototype.format` method. Sorry folks, but extending native prototypes is for suckers.\n- Added a `module.exports = dateFormat;` statement at the bottom\n- Added the placeholder `N` to get the ISO 8601 numeric representation of the day of the week\n\n## Installation\n\n```bash\n$ npm install dateformat\n$ dateformat --help\n```\n\n## Usage\n\nAs taken from Steven's post, modified to match the Modifications listed above:\n\n```js\nimport dateFormat, { masks } from \"dateformat\";\nconst now = new Date();\n\n// Basic usage\ndateFormat(now, \"dddd, mmmm dS, yyyy, h:MM:ss TT\");\n// Saturday, June 9th, 2007, 5:46:21 PM\n\n// You can use one of several named masks\ndateFormat(now, \"isoDateTime\");\n// 2007-06-09T17:46:21\n\n// ...Or add your own\nmasks.hammerTime = 'HH:MM! \"Can\\'t touch this!\"';\ndateFormat(now, \"hammerTime\");\n// 17:46! Can't touch this!\n\n// You can also provide the date as a string\ndateFormat(\"Jun 9 2007\", \"fullDate\");\n// Saturday, June 9, 2007\n\n// Note that if you don't include the mask argument,\n// dateFormat.masks.default is used\ndateFormat(now);\n// Sat Jun 09 2007 17:46:21\n\n// And if you don't include the date argument,\n// the current date and time is used\ndateFormat();\n// Sat Jun 09 2007 17:46:22\n\n// You can also skip the date argument (as long as your mask doesn't\n// contain any numbers), in which case the current date/time is used\ndateFormat(\"longTime\");\n// 5:46:22 PM EST\n\n// And finally, you can convert local time to UTC time. Simply pass in\n// true as an additional argument (no argument skipping allowed in this case):\ndateFormat(now, \"longTime\", true);\n// 10:46:21 PM UTC\n\n// ...Or add the prefix \"UTC:\" or \"GMT:\" to your mask.\ndateFormat(now, \"UTC:h:MM:ss TT Z\");\n// 10:46:21 PM UTC\n\n// You can also get the ISO 8601 week of the year:\ndateFormat(now, \"W\");\n// 42\n\n// and also get the ISO 8601 numeric representation of the day of the week:\ndateFormat(now, \"N\");\n// 6\n```\n\n### Mask options\n\n| Mask             | Description                                                                                                                                                   |\n| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `d`              | Day of the month as digits; no leading zero for single-digit days.                                                                                            |\n| `dd`             | Day of the month as digits; leading zero for single-digit days.                                                                                               |\n| `ddd`            | Day of the week as a three-letter abbreviation.                                                                                                               |\n| `DDD`            | \"Ysd\", \"Tdy\" or \"Tmw\" if date lies within these three days. Else fall back to ddd.                                                                            |\n| `dddd`           | Day of the week as its full name.                                                                                                                             |\n| `DDDD`           | \"Yesterday\", \"Today\" or \"Tomorrow\" if date lies within these three days. Else fall back to dddd.                                                              |\n| `m`              | Month as digits; no leading zero for single-digit months.                                                                                                     |\n| `mm`             | Month as digits; leading zero for single-digit months.                                                                                                        |\n| `mmm`            | Month as a three-letter abbreviation.                                                                                                                         |\n| `mmmm`           | Month as its full name.                                                                                                                                       |\n| `yy`             | Year as last two digits; leading zero for years less than 10.                                                                                                 |\n| `yyyy`           | Year represented by four digits.                                                                                                                              |\n| `h`              | Hours; no leading zero for single-digit hours (12-hour clock).                                                                                                |\n| `hh`             | Hours; leading zero for single-digit hours (12-hour clock).                                                                                                   |\n| `H`              | Hours; no leading zero for single-digit hours (24-hour clock).                                                                                                |\n| `HH`             | Hours; leading zero for single-digit hours (24-hour clock).                                                                                                   |\n| `M`              | Minutes; no leading zero for single-digit minutes.                                                                                                            |\n| `MM`             | Minutes; leading zero for single-digit minutes.                                                                                                               |\n| `N`              | ISO 8601 numeric representation of the day of the week.                                                                                                       |\n| `o`              | GMT/UTC timezone offset, e.g. -0500 or +0230.                                                                                                                 |\n| `p`              | GMT/UTC timezone offset, e.g. -05:00 or +02:30.                                                                                                               |\n| `s`              | Seconds; no leading zero for single-digit seconds.                                                                                                            |\n| `ss`             | Seconds; leading zero for single-digit seconds.                                                                                                               |\n| `S`              | The date's ordinal suffix (st, nd, rd, or th). Works well with `d`.                                                                                           |\n| `l`              | Milliseconds; gives 3 digits.                                                                                                                                 |\n| `L`              | Milliseconds; gives 2 digits.                                                                                                                                 |\n| `t`              | Lowercase, single-character time marker string: a or p.                                                                                                       |\n| `tt`             | Lowercase, two-character time marker string: am or pm.                                                                                                        |\n| `T`              | Uppercase, single-character time marker string: A or P.                                                                                                       |\n| `TT`             | Uppercase, two-character time marker string: AM or PM.                                                                                                        |\n| `W`              | ISO 8601 week number of the year, e.g. 4, 42                                                                                                                  |\n| `WW`             | ISO 8601 week number of the year, leading zero for single-digit, e.g. 04, 42                                                                                  |\n| `Z`              | US timezone abbreviation, e.g. EST or MDT. For non-US timezones, the GMT/UTC offset is returned, e.g. GMT-0500                                                |\n| `'...'`, `\"...\"` | Literal character sequence. Surrounding quotes are removed.                                                                                                   |\n| `UTC:`           | Must be the first four characters of the mask. Converts the date from local time to UTC/GMT/Zulu time before applying the mask. The \"UTC:\" prefix is removed. |\n\n### Named Formats\n\n| Name              | Mask                           | Example                  |\n| ----------------- | ------------------------------ | ------------------------ |\n| `default`         | `ddd mmm dd yyyy HH:MM:ss`     | Sat Jun 09 2007 17:46:21 |\n| `shortDate`       | `m/d/yy`                       | 6/9/07                   |\n| `paddedShortDate` | `mm/dd/yyyy`                   | 06/09/2007               |\n| `mediumDate`      | `mmm d, yyyy`                  | Jun 9, 2007              |\n| `longDate`        | `mmmm d, yyyy`                 | June 9, 2007             |\n| `fullDate`        | `dddd, mmmm d, yyyy`           | Saturday, June 9, 2007   |\n| `shortTime`       | `h:MM TT`                      | 5:46 PM                  |\n| `mediumTime`      | `h:MM:ss TT`                   | 5:46:21 PM               |\n| `longTime`        | `h:MM:ss TT Z`                 | 5:46:21 PM EST           |\n| `isoDate`         | `yyyy-mm-dd`                   | 2007-06-09               |\n| `isoTime`         | `HH:MM:ss`                     | 17:46:21                 |\n| `isoDateTime`     | `yyyy-mm-dd'T'HH:MM:sso`       | 2007-06-09T17:46:21+0700 |\n| `isoUtcDateTime`  | `UTC:yyyy-mm-dd'T'HH:MM:ss'Z'` | 2007-06-09T22:46:21Z     |\n\n### Localization\n\nDay names, month names and the AM/PM indicators can be localized by\npassing an object with the necessary strings. For example:\n\n```js\nimport { i18n } from \"dateformat\";\n\ni18n.dayNames = [\n  \"Sun\",\n  \"Mon\",\n  \"Tue\",\n  \"Wed\",\n  \"Thu\",\n  \"Fri\",\n  \"Sat\",\n  \"Sunday\",\n  \"Monday\",\n  \"Tuesday\",\n  \"Wednesday\",\n  \"Thursday\",\n  \"Friday\",\n  \"Saturday\",\n];\n\ni18n.monthNames = [\n  \"Jan\",\n  \"Feb\",\n  \"Mar\",\n  \"Apr\",\n  \"May\",\n  \"Jun\",\n  \"Jul\",\n  \"Aug\",\n  \"Sep\",\n  \"Oct\",\n  \"Nov\",\n  \"Dec\",\n  \"January\",\n  \"February\",\n  \"March\",\n  \"April\",\n  \"May\",\n  \"June\",\n  \"July\",\n  \"August\",\n  \"September\",\n  \"October\",\n  \"November\",\n  \"December\",\n];\n\ni18n.timeNames = [\"a\", \"p\", \"am\", \"pm\", \"A\", \"P\", \"AM\", \"PM\"];\n```\n\n\u003e Notice that only one language is supported at a time and all strings\n\u003e _must_ be present in the new value.\n\n### Breaking change in 2.1.0\n\n- 2.1.0 was published with a breaking change, for those using localized strings.\n- 2.2.0 has been published without the change, to keep packages refering to ^2.0.0 to continue working. This is now branch v2_2.\n- 3.0.\\* contains the localized AM/PM change.\n\n## License\n\n(c) 2007-2009 Steven Levithan [stevenlevithan.com][stevenlevithan], MIT license.\n\n[dateformat]: http://blog.stevenlevithan.com/archives/date-time-format\n[stevenlevithan]: http://stevenlevithan.com/\n","funding_links":[],"categories":["Packages","包","Repository","目录","Uncategorized","JavaScript","Date","Number"],"sub_categories":["Date","日期","Date \u0026 Time","日期处理","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelixge%2Fnode-dateformat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelixge%2Fnode-dateformat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelixge%2Fnode-dateformat/lists"}