{"id":18498538,"url":"https://github.com/xpodev/better-date","last_synced_at":"2025-08-13T05:04:11.393Z","repository":{"id":91064534,"uuid":"397248073","full_name":"xpodev/better-date","owner":"xpodev","description":null,"archived":false,"fork":false,"pushed_at":"2021-10-10T14:53:25.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-25T17:43:00.879Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/xpodev.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":"2021-08-17T12:29:21.000Z","updated_at":"2021-10-10T14:53:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"195f012a-6557-451b-a57d-a3a463a13269","html_url":"https://github.com/xpodev/better-date","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpodev%2Fbetter-date","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpodev%2Fbetter-date/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpodev%2Fbetter-date/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpodev%2Fbetter-date/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xpodev","download_url":"https://codeload.github.com/xpodev/better-date/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239217107,"owners_count":19601593,"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-11-06T13:41:07.320Z","updated_at":"2025-02-17T00:44:58.794Z","avatar_url":"https://github.com/xpodev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# better-date\n\nDate library with formatting and representation.\n\n## Installing\n```\nnpm i better-date\n```\n\n## Formatting\nFormat example:\n```js\nvar { DatePlus } = require(\"better-date\");\nvar date = new DatePlus();\nconsole.log(date.format(\"DD/MM/YY HH:mm:ss\")); // Will pint something like 17/08/21 15:40:05\n```\n### Format letters table\n| Letters | Meaning                                                     |\n|---------|-------------------------------------------------------------|\n| S       | milliseconds                                                |\n| s       | seconds                                                     |\n| ss      | 2 digits seconds                                            |\n| m       | minutes                                                     |\n| mm      | 2 digits minutes                                            |\n| h       | hours                                                       |\n| hh      | 2 digits hours                                              |\n| D       | day of the month                                            |\n| DD      | 2 digits day of the month                                   |\n| EEE     | 3 first letters day of the week (e.g. Sun)                  |\n| EEEE    | full name day of the week (e.g. Sunday)                     |\n| M       | month, it will convert to the actual month (e.g. April - 4) |\n| MM      | 2 digits month                                              |\n| MMM     | 3 first letter month (e.g. Apr)                             |\n| MMMM    | full name month (e.g. April)                                |\n| YY      | 2 digits year (e.g. 21)                                     |\n| YYY     | full year (e.g. 2021)                                       |\n\n## Time constants\nDatePlus comes with some useful objects.\n\n`DatePlus.TIME` is an object holds all the time steps as their milliseconds values.\n\n`DatePlus.DAYS` is an array that holds the days of the week names (Sunday is on index 0).\n\n`DatePlus.MONTHS` is an array that holds the months names.\n\n\n## Representing\nUsing the `represent` function will return a string that represents when the date object time is compared to now.\nUsage example:\n```js\nvar { DatePlus } = require(\"better-date\");\nvar fiveHoursFromNow = new DatePlus(Date.now() + DatePlus.TIME.HOUR * 5);\nvar fiveHoursAgo = new DatePlus(Date.now() - DatePlus.TIME.HOUR * 5);\n\nconsole.log(fiveHoursFromNow.represent()); // \"5 hours ago\"\nconsole.log(fiveHoursAgo.represent()); // \"in 5 hours\"\n```\n\n## More functions\nYou can add specific amount of time to the date object using the functions `addSeconds`, `addMinutes` etc.\n```js\nvar { DatePlus } = require(\"better-date\");\nvar date = new DatePlus().addMinutes(5);\nconsole.log(date.represent()); // \"in 5 minutes\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxpodev%2Fbetter-date","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxpodev%2Fbetter-date","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxpodev%2Fbetter-date/lists"}