SHARE
TWEET

Untitled

a guest Aug 19th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import 'rc-time-picker/assets/index.css';
  2. import React, { Component } from 'react';
  3.  
  4. import TimePicker from 'rc-time-picker';
  5. import moment from 'moment';
  6.  
  7. const format = 'h:mm a';
  8.  
  9.  
  10.  
  11. const now = moment().hour(0).minute(0);
  12.  
  13. class Time extends Component {
  14.  
  15.   constructor(){
  16.     super();
  17.     this.state={
  18.       value : ''
  19.     }
  20.   }
  21.  
  22.   newHandleChange=(value)=>{
  23.     this.setState({
  24.         value:   localStorage.setItem("currentTime",value.format('h:mm a'))
  25.     })
  26.  
  27. }
  28.   render(){
  29.     console.log("state data",this.state.value)
  30.  
  31.     return(
  32.       <div>
  33.            <TimePicker
  34.                   showSecond={false}
  35.                   defaultValue={now}
  36.                   className="xxx"
  37.                   onChange={this.newHandleChange}
  38.                   format={format}
  39.                   use12Hours
  40.                   inputReadOnly
  41.                   fieldName="time"
  42.                 />
  43.       </div>
  44.     )
  45.   }
  46. }
  47.  
  48. export default Time;
  49.      
  50. constructor(props){
  51.     super(props);
  52.     this.state={
  53.       value : ''
  54.     }
  55.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top