R
R
Ramzzes2015-10-17 00:52:25
PHP
Ramzzes, 2015-10-17 00:52:25

Get timestamp for today's 00:00 Moscow time?

The essence of the question is in the title. What is the easiest way to get unix timestamp 00:00 of the current day for the Moscow time zone.
Moreover, the current time zone in the script can be different, and it is not recommended to change it.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ramzzes, 2015-10-17
@Ramzzes

It may be useful to someone, I couldn’t think of an easier one

function GetMidnightTime($timeZone = 'Europe/Moscow')
{
    $d = new \DateTime(null, new \DateTimeZone($timeZone));
    $d->setTime(0, 0, 0);
    return $d->getTimestamp();
}

E
Everal, 2015-10-17
@Everal

date_default_timezone_set
date('Ymd')
strtotime

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question