Ben
Ben

Reputation: 83

Add specific time to timestamp

please, prior to responding with "Duplicate Question", I did not find anything like that one here on Stackoverflow. am injecting a timestamp into my mysql database the following way:

    $insertData['enddate'] = strtotime($this->input->post('openDays'));

this returns the date, but without a time, the output is e. g. 09/17/2013 00:00h

The hour is always the same, and I need this to always be 17:00h

Searching here and on google, I found ways to add minutes or hours to the time, but I always need this to be 17:00h, it is not a variable + XX hours.

Any clue on how to get this solved?

Thanks ;)

Upvotes: 0

Views: 51

Answers (1)

PlantTheIdea
PlantTheIdea

Reputation: 16369

Assuming the data coming in is a date only (09/17/2013, no time components), you can do this just by writing it as a string:

$insertData['enddate'] = strtotime($this->input->post('openDays').' 17:00:00');

the strtotime function is smart enough to make the translation needed.

Upvotes: 1

Related Questions