【发布时间】:2018-05-23 05:04:19
【问题描述】:
我想以 dd mm yy 格式插入日期,这是我的 php 脚本
date_default_timezone_set('Asia/Kolkata');
$date = date('Y-m-d');
$qry="INSERT INTO `nesbaty_offer`( `provider_id`,
`offer_punch`,
`offer_description`,
`terms`,
`sales_discount`,
`referal`,
`duration`,
`billing_type`,
`status`,
`service_location`,
`time`) VALUES('".$provider_id."',
'".$offer_punch."',
'".$offer_description."',
'".$terms."',
'".$sales_discount."',
'".$referral."',
'".$duration."',
'".$billing_type."',
'".$status."',
'".$service_location."',
'".$date."')";
目前是这样存储的
YY-MM-DD
2018-05-22
但我想要这个
22-05-2018
有可能吗?
【问题讨论】:
-
它是这样存储的,因为你的日期格式是
$date = date('Y-m-d');阅读副本。 -
不,你不能在 MySQL 中使用 DD-MM-YY 格式。使用 PHP 日期函数来操作。
-
我如何转换它@hungrykoala
-
阅读我提供的链接。
$originalDate = "2010-03-21"; $newDate = date("d-m-Y", strtotime($originalDate)); echo $newDate; -
但它不是手动的当前日期吗?