Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Datetime to string php


<?php
$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:s');
?>

Comment

date to string in php

Date to string

$date = "2021/03/13";
$newdate= date('d M, Y', strtotime($date));
echo $newdate;
Comment

time to string in php

<?php
$date = '27/06/2020, 04:42:43 PM';
$date = str_replace('/', '-', $date);
echo date('F j, Y, g:i a',strtotime($date));

// output : June 27, 2020, 4:42 pm
?>
Comment

date to string php

$date_string_prepared = date_create("2020-08-07");
$date_string = $date_string_prepared->format("d M Y");
// result 07 Jul 2020
Comment

Convert DateTime to String in PHP

phpCopy$theDate    = new DateTime('2020-03-08');
echo $stringDate = $theDate->format('Y-m-d H:i:s');

//output: 2020-03-08 00:00:00
Comment

Convert DateTime to String in PHP

phpCopy$date = date_create_from_format('d M, Y', '08 Mar, 2020');
echo $newFormat = date_format($date,"Y/m/d H:i:s");

//output: 2020/03/08 00:00:00
Comment

Convert DateTime to String in PHP

phpCopy$dateFormat = new DateTime(); // this will return current date
echo $stringDate = $date->format(DATE_ATOM);

//output: 2020-03-08T12:54:56+01:00
Comment

Convert DateTime to String in PHP

phpCopydefine ('DATE_ATOM', "Y-m-dTH:i:sP");
define ('DATE_COOKIE', "l, d-M-y H:i:s T");
define ('DATE_ISO8601', "Y-m-dTH:i:sO");
define ('DATE_RFC822', "D, d M y H:i:s O");
define ('DATE_RFC850', "l, d-M-y H:i:s T");
define ('DATE_RFC1036', "D, d M y H:i:s O");
define ('DATE_RFC1123', "D, d M Y H:i:s O");
define ('DATE_RFC2822', "D, d M Y H:i:s O");
define ('DATE_RFC3339', "Y-m-dTH:i:sP");
define ('DATE_RSS', "D, d M Y H:i:s O");
define ('DATE_W3C', "Y-m-dTH:i:sP");
Comment

Convert DateTime to String in PHP

phpCopy$date = explode("/",date('d/m/Y/h/i/s')
list($day,$month,$year,$hour,$min,$sec) = $date);
echo $month.'/'.$day.'/'.$year.' '.$hour.':'.$min.':'.$sec;

//output: 03/08/2020 02:01:06
Comment

PREVIOUS NEXT
Code Example
Php :: php delete element by value 
Php :: php foreach if last item 
Php :: current time in laravel migration 
Php :: check if logged laravel 
Php :: when image update laravel delete remove image 
Php :: define home url wp 
Php :: why use ob_start() in php 
Php :: laravel inline if 
Php :: php mysql date 
Php :: get index of element in array php 
Php :: check if session variable exists php 
Php :: laravel get last record 
Php :: laravel rename column name 
Php :: laravel find or fail exception 
Php :: string to double php 
Php :: twig jsoncencode 
Php :: how to connect to a database in php 
Php :: laravel password verification 
Php :: default port for laravel 
Php :: php copyright footer 
Php :: webhook discord php 
Php :: add zeros in front of number php 
Php :: laravel flutter save image in data 
Php :: php get myme type of image 
Php :: wordpress order by 
Php :: php changr date format 
Php :: how to add property to the request object 
Php :: call table name in model laravel 
Php :: repeater acf 
Php :: how can we use two php version in mac os 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =