php日期格式转换 字符串 sscanf sprintf list

* sscanf.php

<?php
$ts = "2018-09-12T09:40:52.079Z";
list($Y, $m, $d, $H, $i, $s, $Z) = sscanf($ts, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ");
$datetime = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $Y, $m, $d, $H, $i, $s);
echo $datetime.PHP_EOL;

* test

$ php sscanf.php

2018-09-12 09:40:52

* Function Synonym

mixed sscanf ( string $str , string $format [, mixed &$... ] )

http://php.net/manual/en/function.sscanf.php

string sprintf ( string $format [, mixed $args [, mixed $... ]] )

http://php.net/manual/en/function.sprintf.php

array list ( mixed $var1 [, mixed $... ] )

http://php.net/manual/en/function.list.php

string date ( string $format [, int $timestamp = time() ] )

http://php.net/manual/en/function.date.php

sql 创建索引

create index idx_warn_rule_id on warn(rule_id);

sql 创建字段唯一约束

create unique index uniq_config_name on config(name);

猜你喜欢

转载自blog.csdn.net/fareast_mzh/article/details/82907614