dongyong6428 2017-05-30 04:36
浏览 16
已采纳

你如何用PHP重新安排约会(09-09-2013)到(2013-09-09)? [重复]

This question already has an answer here:

I am trying to figure this out, I am not the php developer, but I was tasked with this anyways. So, I have been trying to figure it out. I have been asked to replace the - with commas, and rearrange the dates. For example mm-dd-yyy to yyyy-mm-dd

This is how I replace the -

$TheDate = "09-09-2013";
$TheDate = str_replace('-', ',', $TheDate);
echo $TheDate;

Now, the problem is that I don't even know where to start on how to rearrange the numbers. Could someone please lead me in the right direction?

</div>
  • 写回答

2条回答 默认 最新

  • duankezong4064 2017-05-30 04:41
    关注

    Use php date() and strtotime() to do this. It's the slandered way.

    echo date('Y-m-d',strtotime('09-09-2013'));
    

    Output:- https://eval.in/807312

    Reference:- PHP date formats

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题