Skip to content
Advertisement

PHP: mktime() parse error invalid numeric literal

I need to set variable, let’s call it $times to specific amount of 8AM. I tried using mktime(08,00) but it returns

Parse error: Invalid numeric literal

Since I’m new to php, I still don’t know which function is best used for thing such as this, weather it is time() date() or so.

My question is: how do I set $times to be 8AM of current day?

I’ve checked a lot of similar questions, but none of them have an answer. Not even the one that this is marked duplicate of.

Advertisement

Answer

Just remove the leading zeros.

JavaScript

It’s because PHP is interpreting 08 as an octal number, and 8 is out of range in octal (0-7).

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement