-1

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.

lordsanken
  • 38
  • 11
  • Does this answer your question? [Parse error: Invalid numeric literal](https://stackoverflow.com/questions/40735963/parse-error-invalid-numeric-literal) – CBroe May 12 '22 at 07:33

2 Answers2

2

Just remove the leading zeros.

mktime(8, 0);

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

Liftoff
  • 24,717
  • 13
  • 66
  • 119
0

You can use date()

Dateformat reference: https://www.php.net/manual/en/datetime.format.php

$time = date("H:i") // 08:00 
Jun Pan
  • 362
  • 1
  • 11