Previous Page Next Page

Using the Current Date the U.S./U.K./European Way

<?php
  echo 'US format: ' . date('m/d/Y<b\r />');
  echo 'UK format: ' . date('d/m/Y<b\r />');
  echo 'German format: ' . date('d.m.Y<b\r />');
  echo 'International format: ' . date('Y-d-m');
?>


To give you a short and convenient reference, the preceding code contains several commonly used date formats. Depending on where you are, the order in which day, month, and year are used might vary:

  • In the United States, it's (mostly) month, day, and year

  • In the United Kingdom and the rest of Europe, it's (mostly) day, month, and year

  • The international standard date notation starts with the year and continues with month and day

NOTE

The preceding code used a four-digit representation of the year because this is nonambiguous. In practice, however, two-digit years are also commonly used.



Previous Page Next Page