U
U
Us592020-04-16 14:22:02
PHP
Us59, 2020-04-16 14:22:02

What's wrong with timestamp?

A little before the story: I
changed crontab so that the script was run not through wget, but through /usr/bin/php and then a problem came up:

In the script that runs, there is this line:

CURLOPT_URL            => "https://urladdress.com&timestamp=" . round((microtime(true) * 1000) - (60*60*3/1000)) . "",


And a curl request is sent, but the problem is that if the script runs through cron configured by /usr/bin/php, I get an error in curl .. most likely due to the fact that the timestamp is not correct.

I tried to run the same php file manually through the browser and everything WORKS.
Magic - it would seem, but apparently I don’t know something, tell me please?)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
kn1ght_t, 2020-04-16
@kn1ght_t

in one case, the timestamp is in seconds
, in the other - in milliseconds
, that is, you need to multiply / divide by 1000

N
nokimaro, 2020-04-16
@nokimaro

- (60*60*3/1000)
remove this
microtime() as well as time() return unixtime which is in UTC (GMT + 0) and you don’t need to subtract 3 hours

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question