Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

react-live-clock

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-live-clock

React Live Clock


Version published
Weekly downloads
14K
decreased by-10.84%
Maintainers
1
Weekly downloads
 
Created

react-live-clock npm

Gitter Dependencies Dev Dependencies

React clock with time-zones DEMO

Installation

NPM

npm install --save react react-live-clock

Don't forget to manually install peer dependencies (react) if you use npm@3.

Demo

http://pvoznyuk.github.io/react-live-clock

Usage

import React  from 'react';
import Clock from 'react-live-clock';

exports default class MyComponent extends React.Component {
    render() {
        <Clock format={'HH:mm:ss'} ticking={true} timezone={'US/Pacific'} />
    }
}

Outputs:

<time>10:15:34</time>

** Shows current time for 'US/Pacific' timezone and updates every second

Formatting

you can use any formatting from moment.js date library

Properties

PropertieTypeDefault ValueDescription
datetimestamp or stringcurrent dateDate to output, If nothing is set then it take current date.
formatstring'HH:MM'Formatting from moment.js library.
filterfunction(date: String) => dateFiltering the value before the output .
timezonestringnullIf timezone is set, the date is show in this timezone. You can find the list. here, the TZ column.
tickingbooleanfalseIf you want the clock to be auto-updated every interval seconds.
intervalinteger1000Auto-updating period for the clock. 1 second is a default value.
classNamestringnullExtra class.
childrenstringnulldate can be set as a children prop.
onChangefunction({output, previousOutput, moment}) => {}callback function on each output update

Development and testing

Currently is being developed and tested with the latest stable Node 7 on OSX and Windows.

To run example covering all ReactLiveClock features, use npm start dev, which will compile src/example/Example.js

git clone git@github.com:pvoznyuk/react-live-clock.git
cd react-live-clock
npm install
npm start dev

# then
open http://localhost:8080

Tests

# to run tests
npm start test

# to generate test coverage (./reports/coverage)
npm start test.cov

# to run end-to-end tests
npm start test.e2e

License

This software is released under the MIT license. See LICENSE for more details.

Contributors

FAQs

Package last updated on 27 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts