html怎么写日期php,php匹配html中的日期进行修改并且重新写入html

$id = getgpc('aim_id') ?: "";

$dir = getgpc('dir') ?: "";

$new_date = getgpc('new_date') ?: "";

if (!$id || !$dir) {

$display = 0;

$getMsgByTid = "url不合法";

}

/*操作*/

/*1 wap*/

$array = array('news_id' => $id, 'date_new' => $new_date);

$_ENV['wap_change_record']->add_one($array);

$getMsgByTid = "WAP更新成功!";

/*2 PC 修改文件*/

chmod($dir, 777);

$file_content = file_get_contents($dir);

if ($file_content) {

$date_str = "".date("Y年m月d日",strtotime($new_date))."";

//$patten = "/^\d{4}[\-](0?[1-9]|1[012])[\-](0?[1-9]|[12][0-9]|3[01])(\s+(0?[0-9]|1[0-9]|2[0-3])\:(0?[0-9]|[1-5][0-9])\:(0?[0-9]|[1-5][0-9]))?$/";

$patten = "/\d{4}年(0?[1-9]|1[012])月(0?[1-9]|[12][0-9]|3[01])日/";

$match = preg_match($patten,$file_content);

$update_str = preg_replace($patten, $date_str, $file_content);

$re1 = file_put_contents($dir, $update_str);

// $getMsgByTid .= "换取文字:" . $update_str;

if ($re1) {

$getMsgByTid .= "PC更新成功!";

} else {

$getMsgByTid .= "PC更新失败!";

}

} else {

$getMsgByTid .= "PC未读取到文件:" . $dir;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值