php - How To Convert 1 day To Seconds

Viewed 16162

I am creating a form to set publish interval and want to sum all of the submitted values into seconds. The form consist of fields to determine seconds, minutes, hours, day and so on.

I am collecting the submitted values to string by giving date attributes, like second, minute etc.

For example:

$second second

$minute minute

$hour hour

So if user input 1 in input field to determine the interval in day and 30 in minute, then my code will convert it to string 1 day and 30 minute.

My questions:

1- How can I convert 1 day and 30 minute string into seconds so they can be summed up into correct seconds.

I tried to use strtotime() but it returns a very large number of seconds and date() but it return too small number.

2- Is there a simple function like strtotime() and date() that can do string to second conversion correctly?

2 Answers
Related