duanjigua5753 2010-12-21 15:21
浏览 63
已采纳

格式化数据库的日期编号

Not sure if I should edit this question or just ask another question in a different post. I am having a hard time doing the reverse of what I originally asked. How do I get the "date number" in php. I want to assign the current date number to a variable to so I can use it in my query to compare what is already in the database.

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);
  • 写回答

4条回答 默认 最新

  • du7979 2010-12-21 15:25
    关注

    You're looking for the date function:

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

    For $time_date_data = '2010-08-24 20:00:00.000', you'll get:

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

    You can change the format by changing the first argument to date() according to the docs...

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

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?