dougudu3564 2013-08-10 07:56
浏览 25

如何存储到期时间?

I want to store the expiration time in database. I am using the below code to store expiration time with +1 year.

$cdate = time();
$date = $cdate + 365*24*60*60;
$date = date("Y-m-d H:i:s",$date);

but its not storing the correct time it stores 2014-08-10 07:55:14 but time on storing is 2014-08-10 01:25:14. Aslo not sure its Am or Pm .

Thanks.

  • 写回答

3条回答 默认 最新

  • duanliao6077 2013-08-10 08:14
    关注

    Time/date functions in PHP are using timezones to determine your local time. So if your server is in timezone GMT+6 that means that the date() function will return you the date/time that is 6 hours before GMT.

    You can check the date_default_timezone_set() function manual to find out how PHP is selecting your timezone.

    To set your timezone, you can use date_default_timezone_set() before calling date function or you can set you php.ini setting date.timezone to your timezone.

    For the second part of your question - when formatting time using the date() function the H format character will return 24-hour format of an hour with leading zeros.

    评论

报告相同问题?

悬赏问题

  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思