This topic is locked

Convert string format (ie : 29/12/2020) to date format (ie : 29/12/2020)

7/8/2023 4:14:55 PM
PHPRunner General questions
konenamogo author

Hello,
Sorry my exact following code is :
<?php
$Date_Facture = "291220";
//recup jour1 du champ varchar "Date_Facture"
$jour = substr($Date_Facture,0,2);
$jour = (int)$jour;
echo $jour;
//recup Mois1 du champ varchar "Date_Facture"
$Mois = substr($Date_Facture,2,2);
$Mois = (int)$Mois;
echo $Mois;
//recup Annee1 du champ varchar "Date_Facture"
$Annee = substr($Date_Facture,4,2);
$Annee = $century.$Annee;
$Date1 = $Mois.'/'.$jour.'/'.$Annee;
echo $Date1;
$time = strtotime($Date1);
$newformat = date('d/m/Y',$time);
echo $newformat;
$typeDate = gettype($newformat);
echo $typeDate;
?>
The result:
29
12
12/29/20
29/12/2020
string
Please can you help me to convert string format to date format in php (for having Date type intead of String type in my code above )?
I use PHPRunner 10.8
Thanks

konenamogo author 7/9/2023

Hello,
Finally I got the solution to my problem. I converted the date format through mysql before recovering the date format and doing my processing.the query is:
SELECT CAST(CONCAT(SUBSTRING("290620",5 ,2 ) , SUBSTRING("290620",3 ,2 ) , SUBSTRING("290620",1 ,2 ) ) AS DATE ) as DATE_T_N;