Below are examples on how to use PHP to display the current date and time on the server.
PHP code: |
Result: |
<? echo(date("m/d/y")); ?> |
08/04/26 |
<? echo(date("m/d/Y")); ?> |
08/04/2026 |
<? echo(date("M/d/Y")); ?> |
Aug/04/2026 |
<? echo(date("h.i M/d/Y")); ?> |
02.43 Aug/04/2026 |
<? echo(date("d/m/y"); ?> |
04/08/26 |
<? echo(date("d/m/Y"); ?> |
04/08/2026 |
<? echo(date("d/M/Y"); ?> |
04/Aug/2026 |
<? echo(date("d.m.y")); ?> |
04.08.26 |
<? echo(date("d.m.Y")); ?> |
04.08.2026 |
<? echo(date("d.M.Y")); ?> |
04.Aug.2026 |
<? echo(date("y-m-d")); ?> |
26-08-04 |
<? echo(date("Y-m-d")); ?> |
2026-08-04 |
<? echo(date("Y-M-d")); ?> |
2026-Aug-04 |
<? echo(date("h.i")); ?> |
02.43 |
<? echo(date("h.i.s")); ?> |
02.43.02 |
<? echo(date("H:i")); ?> |
14:43 |
<? echo(date("H:i:s")); ?> |
14:43:02 |
This PHP code example is copyright © 2002-2003 Optima System. All rights reserved worldwide. Unauthorized distribution prohibited. SpinPHP™ User License.