By leflores on
Is there a simple way to obtain current "Drupal" date/time?
When I call date() I simply obtain server date/time, and my server is in a different timezone of what I have setup in System timezone.
I will like to obtain date and time as in the timezone set in Drupal, not the one in the server.
Regards,
Luis
Comments
Use format_date(time(),
Use
format_date(time(), ...).gpk
----
www.alexoria.co.uk
gpk
----
www.alexoria.co.uk
subscribe
subscribe
Drupal samurai for hire, based in Buffalo, New York, USA.
15+ years Drupal, 20+ years web.
http://basicmagic.net
Drupal 7 answer
In Drupal 7 there is a PHP constant that is declared in the bootstrap process:
define('REQUEST_TIME', (int) $_SERVER['REQUEST_TIME']);To use it in code:
$time = REQUEST_TIME;This constant tends to be used in module development for finding a timestamp to use in time/data related methods that stays the same across the entire request process. This way a page request that lasts 3 seconds doesn't have timestamp products using three values.
This value is server related, not client related.
If you are looking for timing related function for timing the length of processes in code, then you may need the time functions:
These are all microtime based methods that will give much better accuracy than a timestamp. The $name is arbitrary, so you can create your own custom timer. The master Drupal timer $name is 'page', so if you do a timer_read('page') you can get microseconds since page_request (approximately.)