© Frank M. Kromann 2016

Frank M. Kromann, PHP and MySQL Recipes, 10.1007/978-1-4842-0605-8_5

5. Dates and Times

Frank M. Kromann

(1)Trabuco Canyon, California, USA

PHP does not have a variable type dedicated to storing date or time values. Instead, integers are used to indicate the number of seconds before or since January 1st, 1970, also called Epoc. When dates and times are treated as a single value they are called a timestamp. The use of integers makes it easy to calculate differences between two timestamps as ordinary math applies.

Recipe 5-1. Working with Time Zones

Problem

All the date and time functions in PHP assume the timestamps to be in Coordinated Universal Time (UTC) . It is necessary to configure PHP to use a specific time zone to convert ...

Get PHP and MySQL Recipes: A Problem-Solution Approach, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.