Skip to content

Instantly share code, notes, and snippets.

@joemsak
Last active December 16, 2016 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joemsak/9684c3e17118767bc4c9c3593a8f1682 to your computer and use it in GitHub Desktop.
Save joemsak/9684c3e17118767bc4c9c3593a8f1682 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import moment from 'moment';
class Clock extends Component {
constructor() {
super()
this.state = {
formattedDateTime: moment().format('MMMM Do YYYY, h:mm:ss a'),
};
}
tick() {
this.setState({
formattedDateTime: moment().format('MMMM Do YYYY, h:mm:ss a'),
});
}
render() {
setTimeout(this.tick.bind(this), 0);
return (
<div className="clock">
{this.state.formattedDateTime}
</div>
)
}
}
export default Clock;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment