“DATETIME ISO 8601 PHP” Kode Jawaban

PHP Convert Tanggal dan Waktu ke ISO 8601

//Object Oriented Method

$datetime = new DateTime('2010-12-30 23:21:46');

echo $datetime->format(DateTime::ATOM); // Updated ISO8601


//Procedural Method

echo date(DATE_ISO8601, strtotime('2010-12-30 23:21:46'));
Disturbed Dugong

DATETIME ISO 8601 PHP

(new DateTime('2022-05-01T16:00:00-03:00'))->format('Y-m-d\TH:i:sp');
Tiago F2

format datetime iso php

$startTime 	= new DateTime($appointment_date . ' ' . $booking_slot[0]); // 2021-12-28 0900
$startTime	= $startTime->format('Y-m-d\TH:i:sp'); // 2021-12-25T12:02:00Z
Strange Squirrel

ISO 8601 PHP


FYI: there's a list of constants with predefined formats on the DateTime object, for example instead of outputting ISO 8601 dates with:

<?php
echo date('c');
?>

or

<?php
echo date('Y-m-d\TH:i:sO');
?>

You can use

<?php
echo date(DateTime::ISO8601);
?>

instead, which is much easier to read.
Dev

Jawaban yang mirip dengan “DATETIME ISO 8601 PHP”

Pertanyaan yang mirip dengan “DATETIME ISO 8601 PHP”

Lebih banyak jawaban terkait untuk “DATETIME ISO 8601 PHP” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya