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

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

巴扎黑
巴扎黑

répondre à tous(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;
左手右手慢动作
<?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']); // 参数:时,分,秒,月,日,年
黄舟

strtotime('2015-10-10');

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!