简体   繁体   English

如何在Airbnb日期范围中使用日期而没有时间-只是日期

[英]How can I use date in Airbnb daterange without time - just date

I'm using airbnb daterange picker in react. 我在反应中使用airbnb daterange选择器。

<DateRangePicker
    startDate={this.state.startDate} // momentPropTypes.momentObj or null,
    startDateId="your_unique_start_date_id" // PropTypes.string.isRequired,
    endDate={this.state.endDate} // momentPropTypes.momentObj or null,
    endDateId="your_unique_end_date_id" // PropTypes.string.isRequired,
    onDatesChange={({ startDate, endDate }) => {
      this.setState({ startDate, endDate });

    }} // PropTypes.func.isRequired,
    focusedInput={this.state.focusedInput} // PropTypes.oneOf([START_DATE, END_DATE]) or null,
    onFocusChange={focusedInput => this.setState({ focusedInput })} // PropTypes.func.isRequired,
    daySize={50}
    noBorder={true}
    isOutsideRange={() => false}
  />

When I select a date I receive a date with time part also, for example : 当我选择一个日期时,我也会收到带有时间部分的日期,例如:

If I select 26 June I'm getting : 如果我选择6月26日,我会得到:

{26/06/2019 12:00:00}

So how could I get only {26/06/2019 00:00:00} 所以我怎么才能只得到{26/06/2019 00:00:00}

Thanks guys Cheers 谢谢大家的欢呼

Your question not related to React. 您的问题与React无关。

I'm guessing that in writing {26/06/2019 12:00:00} you meant for a string: "26/06/2019 12:00:00" or for Date instance: 我猜想以书面形式{26/06/2019 12:00:00}您的意思是字符串: "26/06/2019 12:00:00"Date实例:

 const endDateString = "26/06/2019 12:00:00"; const dateRegex = /\\d{1,2}\\/\\d{1,2}\\/\\d{4}/g const dateString = endDateString.match(dateRegex); console.log(endDateString); // ["26/06/2019"] const endDate = new Date('June 26, 2019 12:00:00'); const fromInstance = `${endDate.getDate()}/${endDate.getMonth()}/${endDate.getFullYear()}` console.log(fromInstance); 

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

相关问题 为什么我不能仅显示日期(日期,月份和年份而没有时间)? - Why can't I display JUST the date (date, month, and year without time)? 我应该使用 `Date()` 在 javascript 中存储没有时间的日期吗 - Should I use `Date()` to store a date without time in javascript 我在表单中使用了日期范围选择器如何禁用从 MySQL 数据库中获取的特定日期范围 - I have used daterange picker in the form how can I disable particular date range which is fetching from MySQL database 如何从下拉列表中获取年份并准备日期,然后在启动日期范围中设置开始日期和结束日期 - How can get year from dropdown and prepare date then set startdate and end date in bootstrap daterange 如何将日期时间倒换为Ajax日期时间 - How can I reverse date time to ajax date time AngularJS DateRange-如何包括结束日期 - AngularJS DateRange - how to include the end date 如何创建一个只包含时间而不是日期的时刻对象? - How do I create a moment object with just the time and not the date? 如何计算当前日期与创建日期的剩余时间? - How can i calculate the remaining time of the current date with the created date? 如何查看 javascript 上的日期和时间? - How can I check date and time on javascript? 我如何使用javascript更改日期的时区而不更改时间 - how do i use javascript change timezone of date without changing the time
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM