Coder Social home page Coder Social logo

logisticinfotech / react-native-datetimepicker Goto Github PK

View Code? Open in Web Editor NEW
5.0 4.0 5.0 1.26 MB

React Native horizontal date picker

Home Page: https://www.logisticinfotech.com/blog/react-native-horizontal-date-picker-library/

License: MIT License

JavaScript 74.28% Python 6.98% Java 4.79% Objective-C 13.96%
react-native react-native-datetime-picker datetimepicker horizontal-datetime-picker react-native-demo react reactnativedemo reactnative-ios datepicker timepicker

react-native-datetimepicker's Introduction

npm version

React Native horizontal date picker

Installation and Usage

Please check this blog for installation and usage this link

Basic Properties

Prop Default Type Description
pickerType datetime enum of ["date","time","datetime"] Type of the picker user want to display.
minDate current date Date Minimum date from picker value start.
maxDate 3 months from current date Date Maximum date upto picker value display.
defaultSelected null Date By default selected date and time.
isShowYear true bool Dispay year above picker.
yearContainerStyle null style Style of the year container.
datePickerContainerStyle null style Style of the date picker.
timePickerContainer null style Style of the time picker.
yearTextStyle null style Style of the year display.
selectedTextStyle null style Style of the selected date or time.
unSelectedTextStyle null style Style of the non selected date or time.
datePickerBG null object or reference Background image of date picker.
timePikerBG null object or reference Background image of time picker.
dayFormat Do string Format of date to display.
monthFormat MMM string Format of month to display.
yearFormat yyyy string Format of year to display.
timeFormat HH:mm string Format of time to display.
timeStep 60 number Amount of the time divide in minutes for time picker.
returnDateFormat DD-MM-YYYY string Return formate of the date selected.
returnTimeFormat hh:mm a string Return formate of the time selected.
returnDateTimeFormat DD-MM-YYYY hh:mm a string Return formate of the full datetime selected.
onDateSelected () => {} function Return date when date is selected.
onTimeSelected () => {} function Return time when date is selected.
onDateTimeSelected () => {} function Return object of date, time and datetime when date or time is selected.

react-native-datetimepicker's People

Contributors

alpesh12 avatar dependabot[bot] avatar kikaninilesh avatar nileshkikani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-native-datetimepicker's Issues

How to limit the time

Hi, is it possible to set minTime and maxTime in the current version? As of right now, it shows time from 00:00 to 23:00 and I want to limit it to 09:00 to 17:00.

minDate is not working

i am setting minDate but it doesnt work, and even in your example its not there can u help me out here. its throwing warning as Warning: Failed prop type: Invalid prop 'minDate' of type 'Object' supplied to 'HorizontalDatePicker'

I am getting the following warnings even though i am using the correct methods

Screenshot 2019-10-27 at 12 11 17 PM

here's the code i have written

export default class CustomDatePicker extends Component {
  constructor(props) {
    super(props);
    this.state = {
      date1: '',
      time1: '',
      dateTime1: '',
      date2: '',
      time2: '',
      dateTime2: '',
      date3: '',
      time3: '',
      dateTime3: '',
    };
  }

  onDateSelected = date => {
    // setTimeout(()=>{}, 5000);
    this.setState({
      date1: date,
      date2: moment(date, 'DD-MM-YYYY').format('DD MMM YYYY'),
      date3: moment(date, 'DD-MM-YYYY').format('Do MMMM YYYY'),
    });
  };

  onTimeSelected = time => {
    this.setState({
      time1: time,
      time2: moment(time, 'hh:mm a').format('HH:mm'),
      time3: moment(time, 'hh:mm a').format('HH:mm a'),
    });
  };

  onDateTimeSelected = datetime => {
    // format="MMMM Do YYYY, h:mm:ss a"
    this.setState({
      dateTime1: datetime.datetime,
      dateTime2: moment(datetime.datetime, 'DD-MM-YYYY hh:mm a').format('DD MMM YYYY 

HH:mm'),
dateTime3: moment(datetime.datetime, 'DD-MM-YYYY hh:mm a').format('MMMM Do YYYY, h:mm:ss a'),
});
};
render() {
const { date1, date2, date3, time1, time2, time3, dateTime1, dateTime2, dateTime3 } =
this.state;
return (


<HorizontalDatePicker
datePickerContainerStyle={{backgroundColor: 'white'}}
timePickerContainerStyle={{backgroundColor: 'white'}}
yearContainerStyle={{backgroundColor: 'white'}}
yearTextStyle={{color: '#31588A', paddingLeft: 200}}
unSelectedTextStyle={[{color: '#31588A'}]}
selectedTextStyle={{color: '#EACF79'}}
onDateSelected={this.onDateSelected}
onTimeSelected={this.onTimeSelected}
onDateTimeSelected={this.onDateTimeSelected}
/>


<Text style={[styles.instructions, styles.textColor1]}>{date1}
<Text style={[styles.instructions, styles.textColor1]}>{time1}
<Text style={[styles.instructions, styles.textColor1]}>{dateTime1}


<Text style={[styles.instructions, styles.textColor2]}>{date2}
<Text style={[styles.instructions, styles.textColor2]}>{time2}
<Text style={[styles.instructions, styles.textColor2]}>{dateTime3}


<Text style={[styles.instructions, styles.textColor3]}>{date3}
<Text style={[styles.instructions, styles.textColor3]}>{time3}
<Text style={[styles.instructions, styles.textColor3]}>{dateTime3}



);
}
}

is there a way that i can select minutes too ?

I am able to select time using this param onTimeSelected={this.onTimeSelected}, is there any way that i can display the minutes in the multiples of 5 and select the minutes, i hope there is a way
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.