react-bootstrap-date-time-picker is built on react-bootstrap and moment, so make sure that you have react-bootstrap and moment in your modules.  Lets see some code.

Install

npm install react-bootstrap-date-time-picker --save

Import

import DateTimePicker from 'react-bootstrap-date-time-picker';

Main Features

  • Can be used as simple date picker
  • Can be used as simple time picker
  • Can be used as simple date-time picker
  • Calendar placement
  • Restricting date-time range

Properties

Here are some important properties of DateTimePicker
  1.   defaultValue - string - default input value
  2.   value - string - input value
  3.   onChange - callback function on change of input value
  4.   onClear - callback function on clear of input value
  5.   onBlur - callback function on blur of input
  6.   onFocus - callback function on focus of input
  7.   autoFocus - bool - setting focus automatically
  8.   disabled - bool - disabling input value
  9.   showClearButton - bool - showing clear button
  10.   calendarPlacement - string - calendar placement, ex: "top", "bottom"
  11.   dateFormat - string- input format, ex: "MM/DD/YYYY HH:mm:ss"
  12.   showTodayButton - bool - showing To Day button calendar ,
  13.   todayButtonLabel - string - To Day button text
  14.   from - Date - lowest possible date for selection
  15.   to - Date - highest possible date for selection
  16.   calendarOnly - bool - If you want to display as only calendar
  17.   timeOnly - bool - If you want to display as only time

Limit Range

The default range is 20 years (10 years back from current date to 10 years after from current date). You can give your own range by passing from and to values. Observe below code 
<DateTimePicker 
 from={new Date("2017-03-15T14:28:06+05:30")} 
 to={new Date("2017-03-30T14:28:06+05:30")} 
 onChange={this.handleChange} 
 value={this.state.date} 
/>

Date Format

Here this library uses momentjs for formatting the date string, So just follow the same formate specifications. Here are some useful formats
  1. DD/MM/YYYY - It will show just date
  2. DD/MM/YYYY HH:mm:ss - It will show date and time 24 hours format
  3. DD/MM/YYYY hh:mm:ss A - It will show date and time 12 hours format
You can follow your own customised date formats based on momentjs
<DateTimePicker 
 dateFormat="DD/MM/YYYY hh:mm:ss A"
/>

Display Calendar only 

Use calendarOnly property to display calendar only and hiding time
<DateTimePicker 
 calendarOnly={true}
/>

Display Time Only

Use timeOnly property to display time only
<DateTimePicker 
 timeOnly={true}
/>

Show or hide clear button

Use showClearButton property to display or hide clear button. Here if you should pass dateFormat, from and to
<DateTimePicker 
 showClearButton={false}
 dateFormat="HH:hh:ss"
 from={fromValue}
 to={toValue}
/>

25 comments:

  1. Very good to read and experiment with ReactJS. You have explained in very easy manner creating Date and Time Picker. Thanks for the write up.

    Best Regards,
    Best ReactJS Training Institute in Hyderabad

    ReplyDelete
  2. Awesome article. I’m most definitely interest in this one. I am in reality happy with article quality and direction. This post is spot on in informative how some ideology applies to any script location. Thanks a lot for preservation huge stuff. I am extremely a good deal grateful used intended for this place. Thanks a lot for protection massive things.
    Best essay writing service

    ReplyDelete
  3. our resume editing service will help you when writing a resume. With us you can get a good resume that will help you get a job

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Wow, great post/ I loved your explanation very mush. It's easy and simple. Yet well, it's full and I don't need to find more extra information. Great job!On the rating of Samedayessay.com your tutorial definitely would be in the top!

    ReplyDelete
  6. Make sure to have react-bootstrap and moment in modules.
    showbox online for PC

    ReplyDelete
  7. I appreciate it!. I really like it when people get together and share ideas. Great website continue the good work!.
    subway surfers online

    ReplyDelete
  8. GBWhatsapp apk Download Latest Version 2018. Download Latest GB Whatsapp for Use 2 Whatsapp in One Mobile.  GBWhatsApp APK

    ReplyDelete
  9. Use dual account with GBwhatsapp Latest Application With free of cost. Gb whatsapp Apk

    ReplyDelete
  10. Catch all movies and shows in Morpheus TV App without any problems in streaming.

    ReplyDelete
  11. Use dual account with GBwhatsapp Latest 7.90 Application With free of cost.

    ReplyDelete
  12. Gbwhatsapp is the best modded app of popular application nowadays. I am very confident to say you will like this app, because its have many features.

    Gbwhatsapp

    ReplyDelete
  13. The post is written in very a good manner and it entails many useful information for me. I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept.

    ReactJS Online Training

    ReplyDelete
  14. Tiap-tiap kemenangan yang telah anda dapatkan kelak temukan anda kerjakan penarikan dana yang berupa uang asli yang dapat setiap saat anda carikan
    asikqq
    dewaqq
    sumoqq
    interqq
    pionpoker
    bandar ceme terpercaya
    hobiqq
    paito warna
    forum prediksi

    ReplyDelete
  15. AppVN is a third-party app store for Android. Unlike Google Play, this app store provides you with some unique features, such as the facility to download certain official premium apps for free.
    https://appvn.one
    AppVN
    Appvn APK
    appvn ios
    appvn apk download

    ReplyDelete
  16. Lucky Patcher Download For Android gives you unlimited in-game resources & removes ads from any type of android application.

    GBWhatsApp Apk:

    GB WhatsApp is the best version of Official WhatsApp.

    ReplyDelete
  17. This comment has been removed by the author.

    ReplyDelete
  18. Really informative article.Really looking forward to read more. Really Cool.
    เว็บไซต์คาสิโนออนไลน์ที่ได้คุณภาพอับดับ 1 ของประเทศ
    เป็นเว็บไซต์การพนันออนไลน์ที่มีคนมา Gclub Royal1688
    และยังมีหวยให้คุณได้เล่น สมัครหวยออนไลน์ ได้เลย
    สมัครสล็อตออนไลน์ได้ที่นี่ >>> Golden slot
    ร่วมลงทุนสมัครเอเย่น Gclubกับทีมงานของเราได้เลย

    ReplyDelete
  19. Im grateful for the blog post.Really thank you!
    โปรโมชั่นGclub ของทางทีมงานตอนนี้แจกฟรีโบนัส 50%
    เพียงแค่คุณสมัคร Gclub กับทางทีมงานของเราเพียงเท่านั้น
    ร่วมมาเป็นส่วนหนึ่งกับเว็บไซต์คาสิโนออนไลน์ของเราได้เลยค่ะ
    สมัครสล็อตออนไลน์ >>> goldenslot
    สนใจร่วมลงทุนกับเรา สมัครเอเย่น Gclub คลิ๊กได้เลย

    ReplyDelete

Blogroll

Follow this blog by Email

Popular Posts