dongliang2058 2013-02-12 03:25
浏览 66

如何与getdate()php一起实现$ _GET

I want to use the $_GET[] along with the getdate() to pull in the date as query string in the form of: YYYY-mm-dd. If no date is entered, then get the current date. This is what I have done, but I don't have a clue as to if I'm close or not.

if(!isset($_GET['date']))
{
//$date = "2012-09-15"; 
$date = date('Y-m-d');
}
elseif(DateTime::createFromFormat('Y-m-d', $_GET['date']))
{
//$date = DateTime::createFromFormat('Y-m-d',$_GET['date']);
$date = $_GET['date'];
}
else
{
$date = date('Y-m-d');
}
$calendar = DateTime::createFromFormat('Y-m-d', $date);

//This is something else I was attempting

//if(isset($_GET['date']) ? $_GET['date'] : $date = date('Y-m-d')
//$date = explode("-", $_GET['date']);
//$date = date('Y-m-d');
// Create new DateTime object passing the date as a string.
$calendar = DateTime::createFromFormat('Y-m-d', $date);
  • 写回答

1条回答 默认 最新

  • dph87312 2013-02-12 03:32
    关注

    not to sure what you are after but the date format for PHP would be something like this

    int strtotime ( string $time [, int $now = time() ] )
    
    评论

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)