{"id":13500882,"url":"https://github.com/phstc/jquery-dateFormat","last_synced_at":"2025-03-29T07:32:03.974Z","repository":{"id":789614,"uuid":"486381","full_name":"phstc/jquery-dateFormat","owner":"phstc","description":"jQuery Plugin to format Date outputs using JavaScript","archived":false,"fork":false,"pushed_at":"2023-12-28T17:25:46.000Z","size":515,"stargazers_count":680,"open_issues_count":18,"forks_count":235,"subscribers_count":39,"default_branch":"master","last_synced_at":"2025-03-23T12:06:15.256Z","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/phstc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"MIT-LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"phstc","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2010-01-24T15:19:15.000Z","updated_at":"2025-03-08T01:34:47.000Z","dependencies_parsed_at":"2024-01-16T10:12:10.203Z","dependency_job_id":null,"html_url":"https://github.com/phstc/jquery-dateFormat","commit_stats":{"total_commits":189,"total_committers":40,"mean_commits":4.725,"dds":0.656084656084656,"last_synced_commit":"d38eac568c9b47b009ac89f08f5580c26daa669b"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Fjquery-dateFormat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Fjquery-dateFormat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Fjquery-dateFormat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Fjquery-dateFormat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phstc","download_url":"https://codeload.github.com/phstc/jquery-dateFormat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246155998,"owners_count":20732355,"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-31T22:01:17.810Z","updated_at":"2025-03-29T07:32:03.705Z","avatar_url":"https://github.com/phstc.png","language":"JavaScript","funding_links":["https://github.com/sponsors/phstc"],"categories":["JavaScript"],"sub_categories":[],"readme":"jquery-dateFormat - jQuery Plugin to format Date outputs using JavaScript - ***Having less than 5kb, jquery-dateFormat is the smallest date format library available!***\n\n[![build passing](https://travis-ci.org/phstc/jquery-dateFormat.png \"build passing\")](http://travis-ci.org/phstc/jquery-dateFormat)\n\n# Installation\n\nDownload latest jquery.dateFormat.js or jquery.dateFormat.min.js.\n\n* [jquery-dateFormat.js](https://raw.githubusercontent.com/phstc/jquery-dateFormat/master/dist/jquery-dateformat.js)\n* [jquery-dateFormat.min.js](https://raw.githubusercontent.com/phstc/jquery-dateFormat/master/dist/jquery-dateformat.min.js)\n* [dateFormat.js](https://raw.github.com/phstc/jquery-dateFormat/master/dist/dateFormat.js) (pure Javascript, no jQuery dependency)\n* [dateFormat.min.js](https://raw.github.com/phstc/jquery-dateFormat/master/dist/dateFormat.min.js) (pure Javascript, no jQuery dependency)\n\nYou can use **jquery-dateFormat without jQuery**. You just need to import the dateFormat.js above and instead of formatting with `$.format(...)` you should use `DateFormat.format(...)`.\n\nIf you use **jQuery Validate** plugin you must use jquery-dateFormat without jQuery.\n\n# Format patterns\n\nThe patterns to formatting are based on [java.text.SimpleDateFormat](http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html).\n\n## Date and time patterns\n\n* yy = short year\n* yyyy = long year\n* M = month (1-12)\n* MM = month (01-12)\n* MMM = month abbreviation (Jan, Feb ... Dec)\n* MMMM = long month (January, February ... December)\n* d = day (1 - 31)\n* dd = day (01 - 31)\n* ddd = day of the week in words (Monday, Tuesday ... Sunday)\n* E = short day of the week in words (Mon, Tue ... Sun)\n* D - Ordinal day (1st, 2nd, 3rd, 21st, 22nd, 23rd, 31st, 4th...)\n* h = hour in am/pm (0-12)\n* hh = hour in am/pm (00-12)\n* H = hour in day (0-23)\n* HH = hour in day (00-23)\n* mm = minute\n* ss = second\n* SSS = milliseconds\n* a = AM/PM marker\n* p = a.m./p.m. marker\n\n# Expected input dates formats\n\n* 1982-10-15T01:10:20+02:00\n* 1982-10-15T01:10:20Z\n* Thu Oct 15 01:10:20 CET 1982\n* 1982-10-15 01:10:20.546\n* Thu Oct 15 1982 01:10:20 GMT-0800 (PST)\n* Thu Oct 15 1982 01:10:20 GMT+0800 (China Standard Time)\n* Thu Oct 15 1982 01:10:20 GMT+0200 (W. Europe Daylight Time)\n* 1982-10-15CET01:10:20\n* JavaScript: new Date().getTime()\n\n[Some examples](https://github.com/phstc/jquery-dateFormat/blob/master/test/format_parse_date_spec.js).\n\n# Usage\n\n```javascript\n \u003cscript\u003e\n   document.write($.format.date(\"2009-12-18 10:54:50.546\", \"Test: dd/MM/yyyy\"));\n   document.write($.format.date(\"Wed Jan 13 10:43:41 CET 2010\", \"dd~MM~yyyy\"));\n \u003c/script\u003e\n```\n\n**Output**\n\n```\n =\u003e Test: 18/12/2009\n =\u003e 13~01~2010\n```\n\n## Formatting using css classes\n\n```html\n  \u003cspan class=\"shortDateFormat\"\u003e2009-12-18 10:54:50.546\u003c/span\u003e\n  \u003cspan class=\"longDateFormat\"\u003e2009-12-18 10:54:50.546\u003c/span\u003e\n```\n\n```javascript\n  jQuery(function() {\n      var shortDateFormat = 'dd/MM/yyyy';\n      var longDateFormat  = 'dd/MM/yyyy HH:mm:ss';\n\n      jQuery(\".shortDateFormat\").each(function (idx, elem) {\n          if (jQuery(elem).is(\":input\")) {\n              jQuery(elem).val(jQuery.format.date(jQuery(elem).val(), shortDateFormat));\n          } else {\n              jQuery(elem).text(jQuery.format.date(jQuery(elem).text(), shortDateFormat));\n          }\n      });\n      jQuery(\".longDateFormat\").each(function (idx, elem) {\n          if (jQuery(elem).is(\":input\")) {\n              jQuery(elem).val(jQuery.format.date(jQuery(elem).val(), longDateFormat));\n          } else {\n              jQuery(elem).text(jQuery.format.date(jQuery(elem).text(), longDateFormat));\n          }\n      });\n  });\n```\n**Output**\n\n```\n =\u003e 18/12/2009\n =\u003e 18/12/2009 10:54:50\n```\n\n## Pretty date formatting\n\n`jQuery.format.prettyDate(value)` returns a string representing how long ago the date represents\n\n* value = String representing ISO time or date in milliseconds or javascript Date object\n```javascript\n jQuery.format.prettyDate(new Date())             // =\u003e \"just now\"\n jQuery.format.prettyDate(new Date().getTime())   // =\u003e \"just now\"\n jQuery.format.prettyDate(\"2008-01-28T20:24:17Z\") // =\u003e \"2 hours ago\"\n jQuery.format.prettyDate(\"2008-01-27T22:24:17Z\") // =\u003e \"Yesterday\"\n jQuery.format.prettyDate(\"2008-01-26T22:24:17Z\") // =\u003e \"2 days ago\"\n jQuery.format.prettyDate(\"2008-01-14T22:24:17Z\") // =\u003e \"2 weeks ago\"\n jQuery.format.prettyDate(\"2007-12-15T22:24:17Z\") // =\u003e \"more than 5 weeks ago\"\n```\n\n## toBrowserTimeZone\n\n`jQuery.format.toBrowserTimeZone(value, format)` converts into browsers timezone.\n\n* value = String representing date in ISO time (\"2013-09-14T23:22:33Z\") or String representing default JAXB formatting of `java.util.Date` (\"2013-09-14T16:22:33.527-07:00\") or String representing Unix Timestamp (Sat Sep 14 2013 16:22:33 GMT-0700 (PDT)) or javascript date object.\n* format = All input formats valid for `jQuery.format.date` are valid for this method. The defaut format is MM/dd/yyyy HH:mm:ss.\n\n### Valid input formats\n\n```javascript\n var date1 = \"2013-09-14T23:22:33Z\";\n var date2 = \"2013-09-14T16:22:33.527-07:00\";\n var date3 = \"Sat Sep 14 2013 16:22:33 GMT-0700 (PDT)\";\n\n $.format.toBrowserTimeZone(date1)\n $.format.toBrowserTimeZone(date2)\n $.format.toBrowserTimeZone(date3)\n```\n\n# Development\n\nTo compile jquery-dateFormat (generate dist files):\n\n```sh\nnpm run compile\n```\n\n## Testing\n\nTests are written using Jasmine. To run the test suite with PhantomJS, run `npm run test`. To run the test suite in your default browser, run `npm run test:browser`.\n\n# Licenses\n\njquery-dateFormat is released under the [MIT License](http://opensource.org/licenses/MIT).\n\n# Do you want to improve jquery-dateFormat\n\nYou're welcome to make your contributions and send them as a pull request.\n\n## Contributors\n\nThanks to [all contributors](https://github.com/phstc/jquery-dateFormat/graphs/contributors).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphstc%2Fjquery-dateFormat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphstc%2Fjquery-dateFormat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphstc%2Fjquery-dateFormat/lists"}