0

I have a vacation request form, I have a two date and time fields. Well one field is start_date and another is end_date. What I want is that when a user goes to create a request, in the field of start_date leave the current date and the time is 08:00, some help?

It should look like this:

Start Date: 28/02/2017 08:00

In the database is also as DATETIME

xerox_12
  • 51
  • 7
  • How are you executing the query? Are you wanting to set that datetime in PHP and pass it as a parameter, or to do it in the query? – Don't Panic Feb 28 '18 at 18:31

1 Answers1

2

You can set time of any DateTime object with this method:

$start_date = (new DateTime)->setTime(8,0)->format('d/m/Y H:i');

Or if you are pulling the datetime from database as string:

$start_date = DateTime::createFromFormat('Y-m-d H:i:s', $yourDateTime)
                  ->setTime(8,0)
                  ->format('d/m/Y H:i');
RDev
  • 1,221
  • 1
  • 12
  • 17