{"id":29019278,"url":"https://github.com/liquidbox/es-formatdate","last_synced_at":"2026-04-28T01:31:35.830Z","repository":{"id":202194463,"uuid":"150013022","full_name":"liquidbox/es-formatdate","owner":"liquidbox","description":"A JavaScript UMD providing a pair of locale-aware date formatting functions for use with the Date object","archived":false,"fork":false,"pushed_at":"2020-01-07T08:33:35.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-26T00:11:25.737Z","etag":null,"topics":["browser","commonjs-modules","date","date-formatting","datetime","ecmascript","formatter","i18n","internationalization","javascipt","l10n","locale","locale-aware","localization","node-module","nodejs","time","utc"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/liquidbox.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}},"created_at":"2018-09-23T18:26:23.000Z","updated_at":"2020-01-07T08:33:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"0deb3898-e6c8-4d6b-93dc-4e5ab1e6e684","html_url":"https://github.com/liquidbox/es-formatdate","commit_stats":null,"previous_names":["liquidbox/es-formatdate"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/liquidbox/es-formatdate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liquidbox%2Fes-formatdate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liquidbox%2Fes-formatdate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liquidbox%2Fes-formatdate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liquidbox%2Fes-formatdate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liquidbox","download_url":"https://codeload.github.com/liquidbox/es-formatdate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liquidbox%2Fes-formatdate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32362780,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"ssl_error","status_checked_at":"2026-04-27T20:07:00.910Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["browser","commonjs-modules","date","date-formatting","datetime","ecmascript","formatter","i18n","internationalization","javascipt","l10n","locale","locale-aware","localization","node-module","nodejs","time","utc"],"created_at":"2025-06-26T00:10:13.900Z","updated_at":"2026-04-28T01:31:35.814Z","avatar_url":"https://github.com/liquidbox.png","language":"TypeScript","readme":"# formatDate\n\nThis JavaScript Universal Module Definition provides the pair of locale-aware date formatting functions \u003ccode\u003eformatDate()\u003c/code\u003e and \u003ccode\u003eformatUTCDate()\u003c/code\u003e for use with the \u003ccode\u003eDate()\u003c/code\u003e object.\n\n## Installing\n\n```sh\nnpm install @liquidbox/format-date\n```\n\nThis command installs the package locally.\n\n### Loading\n\n\u003cstrong\u003eCommonJS/Node.js module systems\u003c/strong\u003e\n\n```js\nconst { formatDate, formatUTCDate } = require('@liquidbox/format-date');\n```\n\n\u003cstrong\u003eES6 module importing\u003c/strong\u003e\n\n```ts\nimport { formatDate, formatUTCDate } from '@liquidbox/format-date';\n```\n\n\u003cstrong\u003eHTML document embedding\u003c/strong\u003e\n\n```html\n\u003cscript src=\"/node_modules/@liquidbox/format-date/lib/index.js\" /\u003e\n```\n\n## Description\n\n```ts\nfunction formatDate(locale?: string | string[], format: string, date: Date = new Date()): string\n```\n\nReturns a string formatted according to the given format string using the given object \u003ccode\u003edate\u003c/code\u003e or the current date if no date is given. In other words, \u003ccode\u003edate\u003c/code\u003e is optional and defaults to the value of \u003ccode\u003enew Date()\u003c/code\u003e.\n\n```ts\nfunction formatUTCDate(locale?: string | string[], format: string, date: Date = new Date()): string\n```\n\nIdentical to the \u003ccode\u003eformatDate()\u003c/code\u003e function except that the time returned is UTC.\n\n## Parameters\n\n* \u003cstrong\u003elocale\u003c/strong\u003e (optional): A string with a BCP 47 language tag. To use the default locale, omit this argument.\n* \u003cstrong\u003eformat\u003c/strong\u003e: The format of the outputted date string. See the formatting options below.\n\n| Format Character | Description | Example Returned Values |\n|---|---|---|\n| *Day* | ... | ... |\n| d | Day of the month, 2 digits with leading zeros | *01* to *31* |\n| D | A textual representation of a day, three letters | *Mon* to *Sun* |\n| j | Day of the month without leading zeros | *1* to *31* |\n| l (lowercase L) | A full textual representation of the day of the week | *Sunday* to *Saturday* |\n| N | ISO-8601 numeric representation of the day of the week | *1* (for Monday) to *7* (for Sunday) |\n| S | English ordinal suffix for the day of the month, 2 characters | *st*, *nd*, *rd*, or *th* |\n| w | Numeric representation of the day of the week | *0* (for Sunday) to *6* (for Saturday) |\n| z | The day of the year (starting from 0) | *0* to *365* |\n| *Week* | ... | ... |\n| W | ISO-8601 week number of year, weeks starting on Monday | e.g.: *42* |\n| *Month* | ... | ... |\n| F | A full textual representation of a month, such as January or March | *January* to *December* |\n| m | Numeric representation of a month, with leading zeros | *01* to *12* |\n| M | A short textual representation of a month, three letters | *Jan* to *Dec* |\n| n | Numeric representation of a month, without leading zeros | *1* to *12* |\n| t | Number of days in the given month | *28* to *31* |\n| *Year* | ... | ... |\n| L | Whether it's a leap year | *1* if leap year, *0* otherwise |\n| o | ISO-8601 week-numbering year. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. | e.g.: *1999* or *2020* |\n| Y | A full numeric representation of a year, 4 digits | e.g.: *1999* or *2020* |\n| y | A two digit representation of a year | e.g.: *99* or *20* |\n| *Time* | ... | ... |\n| a | Lowercase Ante meridiem and Post meridiem | *am* or *pm* |\n| A | Uppercase Ante meridiem and Post meridiem | *AM* or *PM* |\n| B | Swatch Internet Time (or .beat time) | *000* to *999* |\n| g | 12-hour format of an hour without leading zeros | *1* to *12* |\n| G | 24-hour format of an hour without leading zeros | *0* to *23* |\n| h | 12-hour format of an hour with leading zeros | *01* to *12* |\n| H | 24-hour format of an hour with leading zeros | *00* to *23* |\n| i | Minutes with leading zeros | *00* to *59* |\n| s | Seconds with leading zeros | *00* to *59* |\n| v | Milliseconds | e.g.: *321* |\n| *Timezone* | ... | ... |\n| e | Timezone identifier | e.g.: *UTC*, *America/Toronto*, ... |\n| O | Difference to Greenwich time (GMT) without colon between hours and minutes | e.g.: *+0200* |\n| P | Difference to Greenwich time (GMT) with colon between hours and minutes | e.g.: *+02:00* |\n| T | Timezone abbreviation | e.g.: *EST*, *BST*, ... |\n| Z | Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. | *-43200* to *50400* |\n| *Full Date/Time* | ... | ... |\n| c | ISO-8601 date | e.g.: *2004-02-12T15:19:21+00:00* |\n| r | RFC 2822 formatted date | e.g.: *Thu, 21 Dec 2000 16:01:07 +0200* |\n| U | Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) | |\n\nUnrecognized characters in the format string will be printed as-is. The Z format will always return *0* when using \u003ccode\u003eformatUTCDate()\u003c/code\u003e.\n\n* \u003cstrong\u003edate\u003c/strong\u003e (optional): A \u003ccode\u003eDate()\u003c/code\u003e object, defaults to the value of \u003ccode\u003enew Date()\u003c/code\u003e.\n\n## Return Values\n\nReturns a formatted date string.\n\n## Usage\n\n\u003cstrong\u003eExample #1 Usage examples\u003c/strong\u003e\n\n```javascript\n// prints something like: Monday\nconsole.log(formatDate('l'));\n\n// prints something like: Monday 8th of August 2005 03:12:46 PM\nconsole.log(formatDate('l jS \\\\of F Y h:i:s A'));\n\n// prints: July 1, 2000 is on a Saturday\nconsole.log(\"July 1, 2000 is on a \" + formatDate('l', new Date(\"July 1, 2000\")));\n\n/* use variables in the format parameter */\n// prints something like: Wednesday, 25-Sep-2013 15:28:57 MST\nvar cookieFormat = 'D, d-M-Y H:i:s O';\nconsole.log(formatDate(cookieFormat));\n\n// prints: 2000-07-01T00:00:00+00:00\nconsole.log(formatUTCDate('Y-m-d\\\\TH:i:sP', new Date(Date.UTC(2000, 6, 1))));\n```\n\n\u003cstrong\u003eExample #2 Escaping characters\u003c/strong\u003e\n\n```javascript\n/* escape the backslash character */\n// prints something like: Friday the 13th\nconsole.log(formatDate('l \\\\t\\\\h\\\\e jS'));\n```\n\nNote that you should escape any other characters, as any which currently have a special meaning will produce undesirable results, and other characters may be assigned meaning in future versions.\n\nSome examples of Date formatting.\n\n\u003cstrong\u003eExample #3 Formatting\u003c/strong\u003e\n\n```javascript\n// assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the Mountain Standard Time (MST) Time Zone\n\ntoday = formatDate('F j, Y, g:i a');                           // March 10, 2001, 5:16 pm\ntoday = formatDate('m.d.y');                                   // 03.10.01\ntoday = formatDate('j, n, Y');                                 // 10, 3, 2001\ntoday = formatDate('Ymd');                                     // 20010310\ntoday = formatDate('h-i-s, j-m-y, it is w Day');               // 05-16-18, 10-03-01, 1631 1618 6 Satpm01\ntoday = formatDate('\\\\i\\\\t \\\\i\\\\s \\\\t\\\\h\\\\e jS \\\\d\\\\a\\\\y.');   // it is the 10th day.\ntoday = formatDate('D M j G:i:s T Y');                         // Sat Mar 10 17:16:18 MST 2001\ntoday = formatDate('H:m:s \\\\m \\\\i\\\\s\\\\ \\\\m\\\\o\\\\n\\\\t\\\\h');      // 17:03:18 m is month\ntoday = formatDate('H:i:s');                                   // 17:16:18\ntoday = formatDate('Y-m-d H:i:s');                             // 2001-03-10 17:16:18 (the MySQL DATETIME format)\n```\n\nTo format dates in other languages, set the \u003ccode\u003elocale\u003c/code\u003e parameter.\n\n\u003cstrong\u003eExample #4 Localization\u003c/strong\u003e\n\n```javascript\n// assuming today is December 25th, 2018, in the Gregorian calendar\n\nchristmas = formatDate('ar-AE', 'F j Y');    // ديسمبر ٢٥ ٢٠١٨\nchristmas = formatDate('zh-Hans', 'F j Y');  // 十二月 25 2018年\nchristmas = formatDate('th', 'F j Y');       // ธันวาคม 25 พ.ศ. 2561\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliquidbox%2Fes-formatdate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliquidbox%2Fes-formatdate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliquidbox%2Fes-formatdate/lists"}