gpt4 book ai didi

php - 格式化数据库中的日期编号

转载 作者:行者123 更新时间:2023-11-29 04:13:23 25 4
gpt4 key购买 nike

不确定我是应该编辑这个问题还是在不同的帖子中问另一个问题。我很难做与我最初要求的相反的事情。如何在 php.ini 中获取“日期编号”?我想将当前日期编号分配给一个变量,以便我可以在查询中使用它来比较数据库中已有的内容。

I can not see the SQL Server database but I am connecting to it using ODBC and PHP on a Linux box. I was told that the field "meeting_start" was a "Date Number". When I get the value of the "meeting_start" the format looks like this.

2010-08-24 20:00:00.000 

I need both the date and time but for different parts of my function. Is there a way to extract the data for the date and save to a variable and then extract the data for the time and save to a different variable. Below is me trying to take a stab at it.

$time_date_data = "2010-08-24 20:00:00.000"

$meeting_date = get_date($time_date_data);

$meeting_time = get_time($time_date_data);

最佳答案

您正在寻找 date功能:

$meeting_date = date('Y-m-d', strtotime($time_date_data));
$meeting_time = date('H:i', strtotime($time_date_data));

对于 $time_date_data = '2010-08-24 20:00:00.000',您将得到:

$meeting_date = '2010-08-24';
$meeting_time = '20:00';

您可以根据文档将第一个参数更改为 date() 来更改格式...

关于php - 格式化数据库中的日期编号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4500786/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com