我输入了今天的日期,但是在我的任务中它显示了前一天的日期,例如,如果我在任务中输入了1/7/2020,它显示了30/6/2020我尝试删除时间,但仍然显示00:00,我是不知道为什么它显示以前的日期
import React, { useState } from 'react';
import uuid from 'react-uuid';
import { useSelector, useDispatch } from 'react-redux';
import DatePicker from 'react-datepicker';
import 'react-datepicker/dist/react-datepicker.css';
import database from '../firebase/firebase';
import '../App.css';
const AddTasks = () => {
const dispatch = useDispatch();
const newLocal = null;
const [selectedDate, setSelectedDate] = useState(newLocal);
const [task, setTask] = useState('');
const date = new Date()
const userId = useSelector(state => state.auth.uid);
const addTask = () => {
console.log(userId);
console.log('addedAt');
const payload = { id: uuid(), text: task, completed: false, addedAt: JSON.stringify(selectedDate)}
const dbtasksWrapper = database.ref().child(userId).child('tasks');
return dbtasksWrapper.child(payload.id).update(payload).then(() => {
setTask('');
setSelectedDate(null);
dispatch({ type: "ADD_TASKS", payload })
})
}
return (
<form onSubmit={e => {
e.preventDefault(e.target.value);
addTask();
} }>
<input className="input-group-prepend" value={task} placeholder="Enter your Task" onChange={e => setTask(e.target.value)} />
我有删除时间,但我的任务列表仍显示00:00
<DatePicker className="input-group-prepend"
placeholderText="Enter task date "
selected={selectedDate} onChange={(date) => setSelectedDate(date)}
dateFormat="MMMM d, yyyy "
minDate={date} />
<br />
<input className="btn btn-primary" type='submit' value='Submit' />
</form>
);
};
export default AddTasks;
答案 0 :(得分:0)
我认为,您的问题是您要将select t1.* from table1 t1
union all
select t2.*, (select t1.country from table1 t1 where t1.name = t2.name)
from table2 t2
上的minDate
道具设置为今天(即Datepicker
)。要解决此问题,您需要做的就是像这样删除道具:
new Date()
或者,这是指向working sandbox的链接。
希望这会有所帮助!