If the the date is in a string format like "20142311.235504" then this can easily be convert to a proper php date object with one line code.

How to split a date string into a date object in php

If the string is a date, you can do this :

$num = "20142311.235504";

// You create a date with your string according to your current format
$date = date_create_from_format("Ydm.His", $num);

// Now you can play with it
$formattedDate = $date->format("Y/d/m H:i:s"); // `string(19) "2014/23/11 23:55:04"` 

$dateTest['year']  = $date->format("Y"); // 2014
$dateTest['Month'] = $date->format("m"); // 11
$dateTest['day']   = $date->format("d"); // 23
$dateTest['hour']  = $date->format("H"); // 23
$dateTest['min']   = $date->format("i"); // 55
$dateTest['sec']   = $date->format("s"); // 04‚Äč

1 Comments

Oyelyrics Admin

March 03, 2022 at 09:04 am

wow. thanks a lot for this. exactly what i looked for.

Leave a reply

* Your email/mobile address will not be published. required fields are marked.

* Email and mobile number will be verified before publishing the comments.

Name *
Email *
Mobile