sergioccrr/datetimespanish

将文本日期表示转换为西班牙语

v1.0 2021-10-24 18:16 UTC

This package is auto-updated.

Last update: 2024-09-10 00:08:14 UTC


README

A simple extension of the native DateTime class that allows to represent months and days of the week in Spanish.

动机

您可以使用 setlocale 函数实现此功能,但这需要您在系统上安装了区域设置,并且还是一个丑陋的全局设置。

示例

<?php

echo (new DateTimeSpanish)->setDate(2020, 1, 6)->format('l, d F Y');
// Return "Lunes, 06 Enero 2020"

// Instead of:

echo (new DateTime)->setDate(2020, 1, 6)->format('l, d F Y');
// Return "Monday, 06 January 2020"