[日期]将dd / mm / yyyy转换为YYYY-MM-DD? [英] [Date] Converting dd/mm/yyyy to YYYY-MM-DD?

查看:276
本文介绍了[日期]将dd / mm / yyyy转换为YYYY-MM-DD?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好


我的网站托管在美国的服务器上,因此设置为使用

mm / dd / yyyy日期格式而不是欧洲dd / mm / yyyy。


另外,MySQL将日期存储为yyyy-mm-dd,所以我需要转换

dd / mm / yyyy那种格式。我是新手,并没有通过谷歌找到答案

: - /


除了strtotime之外我还需要调用另一个函数吗? ()要发生这种情况吗?$ / b

--------------------
//格式为dd / mm / yyyy

$ dateorig = $ _POST [" dateorig"];


//不不行,因为服务器设置为假设mm / dd / yyyy!

$ new_dateorig = date(" Ym-d",strtotime($ dateorig));

打印$ new_dateorig;

--------------------


谢谢你。

Hello

My site is hosted on a server in the US, hence set up to use
the mm/dd/yyyy date format instead of the European dd/mm/yyyy.

Also, MySQL stores dates as yyyy-mm-dd, so I need to convert
dd/mm/yyyy to that format. I''m a newbie, and didn''t find the answer
through Google :-/

Do I need to call another function in addition to strtotime() to make
this happen?

--------------------
//In the form dd/mm/yyyy
$dateorig = $_POST["dateorig"];

//Doesn''t work because server set up to assume mm/dd/yyyy!
$new_dateorig = date("Y-m-d", strtotime($dateorig));

print $new_dateorig;
--------------------

Thank you.

推荐答案

dateorig =
dateorig =


_POST [" dateorig"];


//因为服务器设置为mm / dd / yyyy而无法工作!
_POST["dateorig"];

//Doesn''t work because server set up to assume mm/dd/yyyy!


new_dateorig = date(" Ym-d" ,strtotime(
new_dateorig = date("Y-m-d", strtotime(


这篇关于[日期]将dd / mm / yyyy转换为YYYY-MM-DD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆