The Be Sure Blog

Code Snippets | Problem Solving | Tips & Tricks

The Be Sure Blog banner

Date creation and conversion in PHP

posted on 8.1.2023 by Below Surface in "PHP"

Simply use:

date("d.m.Y H:i:s");

To create a date like this:

30.10.2022 20:17:57

You can create dates in different layouts by changing the letters within the string.

d = day
m = month
y = year (last two numbers)
Y = year (all four numbers)

H = hour (24h) h = hour (12h) m = minute s = second

By using the method, the servers clock on which the code is running will provide the time.

Tags:

php
date

More posts of this category

Setting a HTML attribute in PHP

How to add a HTML attribute via PHP

PHP