getdkan/pdlt

PHP日期语言工具

0.1.7 2024-06-12 19:32 UTC

README

Maintainability | Test Coverage

PHP日期语言工具

这是一个简单的解析器生成器,用于读取、处理或转换常规日期语言格式。

用法

将 Strptime 转换为 MySQL 日期格式

<?php

use PDLT\CompilationMap\MySQL as MySQLCompilationMap;
use PDLT\Compiler;
use PDLT\Converter;
use PDLT\Grammar\Strptime as StrptimeGrammar;
use PDLT\Parser;

// Build Strptime to MySQL date format converter using Strptime date format
// parser and MySQL date format Compiler.
$strptime_parser = new Parser(new StrptimeGrammar());
$mysql_compiler = new Compiler(new MySQLCompilationMap());
$converter = new Converter($strptime_parser, $mysql_compiler);

// Convert a Strptime date format.
echo $converter->convert('%-m/%-d/%y');
// Output: "%c/%e/%y".

支持的日期格式语言

支持的输入格式

支持的输出格式