简体   繁体   English

如何从ANTD.DESIGN的RangePicker获取startDate和endDate

[英]How To Get startDate and endDate from RangePicker from ANTD.DESIGN

i'm working ing a react js project and I'm using antd.design Library to show a RangePicker what i'm trying to solve is how can i get the start date and the end date from this RangePicker when user select a period that's my code : 我正在处理一个React js项目,并且我正在使用antd.design库显示RangePicker我要解决的问题是,当用户选择一个时间段时,如何从该RangePicker获取开始日期和结束日期我的代码:

            handleChangeDebut =range => {
    const valueOfInput1 = moment(range.startDate).format();
    const valueOfInput2 = moment(range.endDate).format();
    console.log('start date',valueOfInput1); 
    console.log("end date",valueOfInput2);
  }

      <DatePicker.RangePicker
                  style={{ width: "100%" }}
                  getPopupContainer={trigger => trigger.parentNode}
                  onChange={this.handleChangeDebut}
                />

the issue is on my handleChange function , i always get the date of the current day is there any attributes in antd design that give us the startDate and the EndDate Selected ? 问题出在我的handleChange函数上,我总是得到当日的日期。antd设计中是否有任何属性可以使我们选择startDate和EndDate?

Thank you for your precious help . 谢谢您的宝贵帮助。

From the documentation, this is the signature of the onChange function function(dates: moment, moment, dateStrings: string, string) , It looks like start and end date are passed as an array in the first param: 从文档中function(dates: moment, moment, dateStrings: string, string) ,这是onChange函数的签名function(dates: moment, moment, dateStrings: string, string) ,看起来开始日期和结束日期在第一个参数中作为数组传递:

handleChangeDebut = (range) => {
    const valueOfInput1 = range[0].format();
    const valueOfInput2 = range[1].format();

    console.log('start date',valueOfInput1); 
    console.log("end date",valueOfInput2);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MongoDB-从startDate到endDate获取数据 - MongoDB - Get Data from startDate to endDate 从组件外部更新一个 antd RangePicker - Update an antd RangePicker from outside the component 如何找到指定日期的一周的开始日期和结束日期 - How do I find startdate and enddate of the week from the specified date 如何选择从开始日期到结束日期为止的序列化数据(意味着不包括结束日期) - How to select data with sequelize from startdate upto the beginning of enddate (meaning excluding the enddate) 从 HTML 表格计算持续时间 startDate 和 endDate - Calculate duration startDate & endDate from an HTML form 获取4周的开始日期和结束日期 - Get 4 week startdate and enddate 从星期一而不是星期日开始 antd RangePicker (datepicker) 周 - start antd RangePicker (datepicker) week from monday instead of sunday 使用 Node.js 中的 Twilio API 获取从 startDate 到 endDate 的调用列表 - Get a list of calls from startDate to endDate with Twilio API in Node.js 尝试将 startDate 和 endDate 从 spreadsheet1 标记为 spreadsheet2 - Trying to mark startDate and endDate from spreadsheet1 to spreadsheet2 有时间用Ant Design的Rangepicker的值怎么获取? - How to get the value of the Rangepicker which having the time with Ant Design?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM