0

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.

1

2 Answers 2

3

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).

Sign up to request clarification or add additional context in comments.

Comments

0

You can use date()

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

$time = date("H:i") // 08:00 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.