{"id":13671651,"url":"https://github.com/hongmaoxiao/now","last_synced_at":"2025-04-27T18:31:31.628Z","repository":{"id":65464452,"uuid":"109627204","full_name":"hongmaoxiao/now","owner":"hongmaoxiao","description":"now  is a time toolkit for javascript","archived":false,"fork":false,"pushed_at":"2017-12-05T00:05:15.000Z","size":11893,"stargazers_count":58,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T08:04:55.813Z","etag":null,"topics":["date","format","i18n","javascript","now","nowjs","time"],"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/hongmaoxiao.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":"2017-11-06T00:02:37.000Z","updated_at":"2024-11-06T15:27:17.000Z","dependencies_parsed_at":"2023-01-24T17:45:15.813Z","dependency_job_id":null,"html_url":"https://github.com/hongmaoxiao/now","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hongmaoxiao%2Fnow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hongmaoxiao%2Fnow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hongmaoxiao%2Fnow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hongmaoxiao%2Fnow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hongmaoxiao","download_url":"https://codeload.github.com/hongmaoxiao/now/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251187216,"owners_count":21549603,"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":["date","format","i18n","javascript","now","nowjs","time"],"created_at":"2024-08-02T09:01:15.544Z","updated_at":"2025-04-27T18:31:30.005Z","avatar_url":"https://github.com/hongmaoxiao.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"## Now\n\nNow is a time toolkit for javascript\n\n## Overview\n\nNow is inspire by [Now](https://github.com/jinzhu/now)(a time toolkit for golang). When I'm about to complete the code, I found that this is just a total toy. go's standard library time native support Format, Duration and so on. Format and i18n needs a huge amount of work. I found that [moment](https://github.com/moment/moment) had implemented them in a very elegant way. So I borrow it, respect and gratitude!\n## Install\n\nInstall with npm\n\n```\nnpm install now.js\n```\n\nES6/commonjs\n```javascript\n// ES6\nimport Now from 'now.js';\n\n// commonjs\nvar Now = require('now.js');\n```\n\nUsing cdn\n\n```html\n// default support 'en' and 'zh-cn'\n\u003cscript type=\"text/javascript\" src=\"https://unpkg.com/now.js/dist/nowjs.min.js\"\u003e\u003c/script\u003e\n\n// or locale version support 118 languages\n\u003cscript type=\"text/javascript\" src=\"https://unpkg.com/now.js/dist/nowjs.locale.min.js\"\u003e\u003c/script\u003e\n```\n\n## Examples\n```javascript\nvar now = new Now()\n\nnow.format() // \"2017-11-20T22:23:00+08:00\"\nnow.format('YYYY-MM-DD HH:mm:ss.SSS') // \"2017-11-20 22:23:00.285\"\nnow.format(\"dddd, MMMM Do YYYY, h:mm:ss a\") // \"Monday, November 20th 2017, 10:23:00 pm\"\n\nnow.locale('zh-cn') // default support 'en' and 'zh-cn'\nnow.format(\"dddd, MMMM Do YYYY, h:mm:ss a\") // \"星期一, 十一月 20日 2017, 10:23:00 晚上\"\nnow.elapse() // \"10 天前\"\n// same as\nnow.timeAgo() // \"10 天前\"\n\n// monday\nnow.monday() // \"2017-11-20 00:00:00\"\n\n// isMonday\nnow.isMonday() // true\n\n// isBefore\nnow.isBefore(new Date(2020, 10, 11)) // true\n\n// isLeapYear\nnow.isLeapYear() // false\nnow.isLeapYear(2008) // true\n\n// between\nnow.between(new Date(2008, 10, 10), new Date(2018, 10, 10)) // true\n\n// UTC\nnow.UTC().format() // \"2017-11-20T22:23:00+00:00\"\n\nnow.beginningOfMinute()   // \"2017-11-20 22:23:00\"\nnow.beginningOfHour()     // \"2017-11-20 22:00:00\"\nnow.beginningOfDay()      // \"2017-11-20 00:00:00\"\nnow.beginningOfWeek()     // \"2017-11-19 00:00:00\"\nnow.firstDayMonday = true // Set Monday as first day, default is Sunday\nnow.beginningOfWeek()     // \"2017-11-20 00:00:00\"\nnow.beginningOfMonth()    // \"2017-11-01 00:00:00\"\nnow.beginningOfQuarter()  // \"2017-10-01 00:00:00\"\nnow.beginningOfYear()     // \"2017-01-01 00:00:00\"\n\nnow.endOfMinute()         // \"2017-11-20 22:23:59.999\"\nnow.endOfHour()           // \"2017-11-20 22:59:59.999\"\nnow.endOfDay()            // \"2017-11-20 23:59:59.999\"\nnow.endOfWeek()           // \"2017-11-25 23:59:59.999\"\nnow.firstDayMonday = true // Set Monday as first day, default is Sunday\nnow.endOfWeek()           // \"2017-11-26 23:59:59.999\"\nnow.endOfMonth()          // \"2017-11-30 23:59:59.999\"\nnow.endOfQuarter()        // \"2017-12-31 23:59:59.999\"\nnow.endOfYear()           // \"2017-12-31 23:59:59.999\"\n\nAll the above functions return String type. You can pass 'self' to return Now instance:\n\nvar beginningOfMinute = now.beginningOfMinute('self') // return Now instance\nbeginningOfMinute.format('ddd, Ah') // \"Mon, PM10\"\nbeginningOfMinute.format('LLLL') // \"Monday, November 20, 2017 10:23 PM\"\nbeginningOfMinute.isMonday() // true\n\n```\n\n[More examples](https://github.com/hongmaoxiao/now/blob/master/example)\n\n## Localization\nFrom `now.js` 0.3.0, default just supports 'en' and 'zh-cn'.If you want to support more locales. Please use `nowjs.locale.js` or `nowjs.locale.min.js` instead.\n\n## Browser Support\n\nModern browsers and Internet Explorer 9+.\n\n## Contribute\nBug reports or suggestions please check out [issues](https://github.com/hongmaoxiao/now/issues).\u003cbr\u003e\nAny pull request will be apreciated.\n\n1. Fork\n2. run `npm install`\n3. run `npm run start` in the main folder to launch a development webserver\n4. complete your code and create pull request\n\n**Note:**\n\n1. Pull request to `master` branch will be rejected, submit your pull request to `develop` branch.\n2. Do not upload build files in your pull request. These are `dist/*.js`. I will build them by myself.\n\n## Changelog\n\n#### 0.3.0\n1. default version(nowjs.js, nowjs.min.js) and locale version(nowjs.locale.js, nowjs.locale.min.js).\n2. default version just supports 'en' and 'zh-cn' locales; locale version support 118 languages.\n\n#### 0.2.0\n1. fix package.json homepage, repository url and bugs url.\n2. add Contribute to readme.\n\n## Author\n\n**hongmaoxiao**\n\n* \u003chttp://github.com/hongmaoxiao\u003e\n* \u003cbuaaxhm@gmail.com\u003e\n* \u003chttps://twitter.com/buaaxhm\u003e\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhongmaoxiao%2Fnow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhongmaoxiao%2Fnow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhongmaoxiao%2Fnow/lists"}