im的格式化日期为dd-mm-yyyy

问题描述 投票:0回答:1

im在我的数据库中获得注册,因为以dd-mm-yyyy格式输入日期,我也应该怎么做以dd-mm-yyyy格式获取sql?

这里是我的代码,我通过观看来自utube的视频在这里进行了日期格式化,这里是链接https://youtu.be/r_JW1PDZlZo

我试图将其与已经完成的代码合并

im是php的新手,不知道如何更改它们。请以简单的方式逐步重播我]



<html>

<head><h4 style="color:green;" >ADD YOUR DETAILS BELOW </h4>

<script src="https://kit.fontawesome.com/d3d5464d46.js" crossorigin="anonymous"></script>

<script type="text/javascript">
       $(function() {
               $("#datepicker").datepicker({ dateFormat: "dd-mm-yy" }).val()
       });
   </script>
<body style="background: url(img/too.jpg); background-repeat;background-size:100% 100%">

<a href="index.php"><button <i class="fas fa-home"></i>&nbsp; RETURN</button></a>
<br></br>
<br></br>

<form  action="add.php" method = "post" name="form1">

<table>
<link rel="stylesheet" type="text/css" href="style.php?"/>


<tr>
<td>Company Name</td>
<td><input type="text"  name="company_name"  placeholder="companie's name.."></td>
</tr>


<tr>
<td>Client Name </td>
<td><input type="text" name="client_name"  placeholder="your's name.."></td>
</tr>


<tr>
<td>Date of entry</td>
<td><input type="date"   name="date_of_entry" placeholder="DD/MM/YYYY" ></td>
</tr>


<tr>
<td>Phone</td>
<td><input type="text" name="phone" placeholder="phone no"></td>
</tr>
<p>

<tr>
<td></td>
<td><button  type="submit" name="submit" value="ADD" <i class="fas fa-plus"></i>&nbsp;ADD</button></td>
</tr>

</table>
</form>

<?php




if(isset($_POST['submit']))
{
    $comp_nam =$_POST['company_name'];
    $cli_nam =$_POST['client_name'];
    $dat=$_POST['date_of_entry'];
    $phn=$_POST['phone'];

    $resulto= explode('-','/' $dat);
    $date=$resulto[2];
    $month=$resulto[1];
    $year=$resulto[0];

    echo $dat=$date.'-'.$month.'-'.$year;


    include_once"config.php";

    $result= mysqli_query($conn,"INSERT INTO information (company_name,client_name,date_of_entry,phone) VALUES('$comp_nam','$cli_nam','$dat','$phn')")  or die(mysqli_error($conn));


header("location:index.php");

     echo "User added successfully";


}



?>
</body>
</html>

请有人尽快回答我

im在我的数据库中获取注册信息,因为以dd-mm-yyyy格式输入日期,我也应该怎么做才能以dd-mm-yyyy格式获取sql?这是我的代码,我通过观看...

php html mysql
1个回答
0
投票

此echo $ dat = $ date .'-'。$ month .'-'。$ year;

© www.soinside.com 2019 - 2024. All rights reserved.