怎样把类似2015年1月1号这样的数据转化为时间戳 php
巴扎黑
巴扎黑 2017-04-10 16:25:35
0
3
330

php中,怎样把类似2015年1月1号这样的数据转化为时间戳,日期可能是一位,也可能是两位,例如2015年11月4号,2015年4月11号,等等。

巴扎黑
巴扎黑

全員に返信(3)
伊谢尔伦
<?php
/**
 * Created by PhpStorm.
 * User: Bruce
 * Date: 15/12/3
 * Time: 下午2:06
 */
$arr = date_parse_from_format ( "Y年m月d日" , "2015年10月12日" );
$timestamp = mktime(0,0,0,$arr['month'],$arr['day'],$arr['year']);
echo $timestamp;
いいねを押す +0
左手右手慢动作
<?php
header('Content-Type: text/plain;charset=utf-8');
$arr = date_parse_from_format('Y年m月d日', '2015年10月1日');
//下面3个输出都是1443628800
echo strtotime('2015-10-1')."\n";
echo strtotime($arr['year'].'-'.$arr['month'].'-'.$arr['day'])."\n";
echo mktime(0, 0, 0, $arr['month'], $arr['day'], $arr['year']); // 参数:时,分,秒,月,日,年
いいねを押す +0
黄舟

strtotime('2015-10-10');

いいねを押す +0
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!