{"id":21662377,"url":"https://github.com/sd0e/utctorelative","last_synced_at":"2025-10-19T15:15:44.267Z","repository":{"id":57747153,"uuid":"522233683","full_name":"sd0e/utcToRelative","owner":"sd0e","description":"An npm ES module package which converts a UTC time in milliseconds to a relative time (e.g. Tomorrow, 16:00)","archived":false,"fork":false,"pushed_at":"2022-08-17T08:51:56.000Z","size":76,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-19T22:23:37.260Z","etag":null,"topics":["date","javascript","npm","npm-module","npm-package","relative-time","timezone","utc"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/utctorelative","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/sd0e.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}},"created_at":"2022-08-07T14:22:00.000Z","updated_at":"2022-12-10T09:38:21.000Z","dependencies_parsed_at":"2022-09-01T19:31:42.887Z","dependency_job_id":null,"html_url":"https://github.com/sd0e/utcToRelative","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sd0e/utcToRelative","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sd0e%2FutcToRelative","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sd0e%2FutcToRelative/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sd0e%2FutcToRelative/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sd0e%2FutcToRelative/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sd0e","download_url":"https://codeload.github.com/sd0e/utcToRelative/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sd0e%2FutcToRelative/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267931102,"owners_count":24167562,"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","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["date","javascript","npm","npm-module","npm-package","relative-time","timezone","utc"],"created_at":"2024-11-25T10:15:58.194Z","updated_at":"2025-10-19T15:15:44.183Z","avatar_url":"https://github.com/sd0e.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# utcToRelative\r\n\r\nutcToRelative is a package which converts a UTC time (in milliseconds) into a local time string which is relative to the current date. The purpose is to provide the user with an easier to understand time, such as `Tomorrow, 16:00` or `Sunday, 16:00` rather than `7 August 2022, 16:00`.\r\n\r\n## Installation\r\n\r\nutcToRelative can be installed by running `npm i --save utctorelative`.\r\n\r\nIt can be used by writing `import { utcToRelative } from 'utctorelative'` and calling the function `utcToRelative`.\r\n\r\n## Parameters\r\n\r\n### `utc`\r\n\r\nThis is the UTC time in milliseconds from which the relative date string will be calculated.\r\n\r\nThis is passed as an integer (e.g. `1659885783755`).\r\n\r\nThe default value is the current time in milliseconds.\r\n\r\n---\r\n\r\n### `hourFormat`\r\n\r\nThis determines whether the time will be displayed in 12-hour or 24-hour time (e.g. `4:23 pm` or `16:23` respectively).\r\n\r\nThis is passed as a string of either `\"12\"` or `\"24\"`.\r\n\r\nThe default value is `\"24\"`.\r\n\r\n---\r\n\r\n### `monthFormat`\r\n\r\nThis determines whether the month will be displayed in a full or concatenated form (e.g. `August` or `Aug` respectively).\r\n\r\nThis is passed as a string of either `\"full\"` or `\"concat\"`.\r\n\r\nThe default value is `\"full\"`.\r\n\r\n---\r\n\r\n### `currentTime`\r\n\r\nThis is the current UTC time in milliseconds, which will be compared with the `utc` parameter to create a relative date string. This only needs to be defined if you do not want to use the system time as the current time.\r\n\r\nThis is passed as an integer (e.g. `1659885783755`).\r\n\r\nThe default value is the current time in milliseconds, according to the system time.\r\n\r\n## Examples\r\n\r\nFor the purpose of these examples, `1659885783755` is Sunday, 7 August 2022 at 4:23 pm.\r\n\r\nThe following table shows the output of the following code when it is run on the stated days:\r\n\r\n```\r\nimport { utcToRelative } from 'utctorelative';\r\n\r\nconsole.log(utcToRelative(1659885783755, '12'));\r\n```\r\n\r\n| Date | Output |\r\n| --- | --- |\r\n| 20th July, 2021 | 7 August 2022, 4:23 pm |\r\n| 20th July, 2022 | 7 August, 4:23 pm |\r\n| 4th August, 2022 | Sunday, 4:23 pm |\r\n| 6th August, 2022 | Tomorrow, 4:23 pm |\r\n| 7th August, 2022 | Today, 4:23 pm |\r\n| 8th August, 2022 | Yesterday, 4:23 pm |\r\n| 10th August, 2022 | Last Sunday, 4:23 pm |\r\n| 20th August, 2022 | 7 August, 4:23 pm |\r\n| 20th August, 2023 | 7 August 2022, 4:23 pm |","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsd0e%2Futctorelative","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsd0e%2Futctorelative","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsd0e%2Futctorelative/lists"}