-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path09_dates.php
More file actions
28 lines (21 loc) · 802 Bytes
/
Copy path09_dates.php
File metadata and controls
28 lines (21 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
// afficher la date courante
echo date('Y-m-d H:i:s') . '<br>';
// affiche la date d'hier
echo date('Y-m-d H:i:s', time() - 60 * 60 * 24) . '<br>';
// Differents formats: https://www.php.net/manual/en/function.date.php
echo date('F j Y, H:i:s') . '<br>';
// Affiche le timestamp courrant
echo time() . '<br>';
// convertir chaine en date: https://www.php.net/manual/en/function.date-parse.php
$dateString = '2020-02-06 12:45:35';
$parsedDate = date_parse($dateString);
echo '<pre>';
var_dump($parsedDate);
echo '</pre>';
// convertir chaine en date avec format: https://www.php.net/manual/en/function.date-parse-from-format.php
$dateString = 'February 4 2020 12:45:35';
$parsedDate = date_parse_from_format('F j Y H:i:s', $dateString);
echo '<pre>';
var_dump($parsedDate);
echo '</pre>';