duan33360 2014-06-03 16:06
浏览 41
已采纳

PHP mktime通知

I want to change given date and time or date only into Unix time.

I tried like this:

mktime("Jan-12-2012 2:12pm");

But it’s not working:

Even in PHP documentation I looked at many examples and many of them don’t consist the matter that I want.

And when I try:

$user_birthday=$_POST["user_birthday"];
$db_user_birthday=empty($user_birthday)?"":mktime($user_birthday);

$_POST["user_birthday"] was given value from form that is jan-12-2012 2:12pm it show error like this:

Notice: A non well formed numeric value encountered in C:\Program Files (x86)\Ampps\www\admin\index.php on line 76

How do I fix it or display time into Unix?

  • 写回答

3条回答 默认 最新

  • ds78662302 2014-06-03 16:10
    关注

    You should take a look at this answer: convert date to unixtime php

    Essentially, you have mixed up mktime() with strtotime(). strtotime() allows you to parse an English textual string into a Unix timestamp. mktime() constructs a unix datetime based on integer arguments.

    For example (again taken from the question above)

    echo mktime(23, 24, 0, 11, 3, 2009);
    1257290640
    
    echo strtotime("2009-11-03 11:24:00PM"); 
    1257290640
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写