https://github.com/perry-mitchell/is-time
Check if a string is a time value
https://github.com/perry-mitchell/is-time
data-type format time timezone validation
Last synced: 3 months ago
JSON representation
Check if a string is a time value
- Host: GitHub
- URL: https://github.com/perry-mitchell/is-time
- Owner: perry-mitchell
- License: mit
- Created: 2017-05-19T15:22:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-19T20:14:01.000Z (over 8 years ago)
- Last Synced: 2025-01-03T13:23:56.561Z (about 1 year ago)
- Topics: data-type, format, time, timezone, validation
- Language: JavaScript
- Size: 7.81 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# is-time
Check if a string is a time value
[](https://travis-ci.org/perry-mitchell/is-time) [](https://www.npmjs.com/package/is-time)
## About
`is-time` provides a simple function which can be used to test if a value resembles a _time_.
Installation is easy:
```shell
npm install is-time --save
# or
yarn add is-time
```
## Usage
Once imported, simply pass a string value to `isTime`. Non-string values will throw exceptions.
```javascript
const isTime = require("is-time");
isTime("23:43:12+0100"); // true
isTime("12:36:23.237 AM"); // true
isTime("03:71:02 a.m."); // false
isTime(""); // false
isTime({}); // error
```