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条)

报告相同问题?

悬赏问题

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