nim4n/date-format-indonesia
最新稳定版本:0.0.1
Composer 安装命令:
composer require nim4n/date-format-indonesia
包简介
Buat format tanggal bahasa indonesia menggunakan PHP
README 文档
README
Untuk mempermudah membuat format tanggal pada php dalam bahasa indonesia, seperti menampilkan nama hari, menampilkan nama bulan, tahun, jam, dll. Library ini mengextends Carbon dan fungsi2 Carbon bisa di gunakan di library ini
Instalasi menggunakan composer
composer require nim4n/date-format-indonesia
Penggunaan sederhana
include './vendor/autoload.php'; use Nim4n\SimpleDate; $contohFormatTanggal = "2019-08-16 23:21"; SimpleDate::date($contohFormatTanggal); // 16 Agustus 2019 SimpleDate::dayDate($contohFormatTanggal); // Jumat, 16 Agustus 2019 // dengan menggunakan jam dan menit SimpleDate::dateTime($contohFormatTanggal); // 16 Agustus 2019 23:21 SimpleDate::dayDateTime($contohFormatTanggal); // Jumat, 16 Agustus 2019 23:21 // dengan nama hari dan nama bulan di singkat SimpleDate::dayShortMonthDate($contohFormatTanggal); // Jumat, 16 Agt 2019 SimpleDate::dayShortMonthDateTime($contohFormatTanggal); // Jumat, 16 Agt 2019 23:21
Membuat custom format
Kita bisa membuat format tanggal sendiri dengan 2 cara
-
Membuat Global Format
// Usahakan name/keys menggunakan camelCase SimpleDate::addGlobalFormat([ "displayDay" => "[Hari] dddd [Pukul] HH:mm", "fullDate" => "dddd, Do/MMMM/YYYY [Pukul] HH:mm" ]); $contohFormatTanggal = "2019-08-16 23:21"; // lalu panggil keys sebagai method SimpleDate::displayDay($contohFormatTanggal); // Hari Jumat Pukul 23:21 SimpleDate::fullDate($contohFormatTanggal); // Jumat, 16/Agustus/2019 Pukul 23:21 // Menambahkan waktu atau mengurangi waktu SimpleDate::fullDate($contohFormatTanggal)->add(1,"days"); // Sabtu, 17/Agustus/2019 Pukul 23:21 SimpleDate::fullDate($contohFormatTanggal)->add(-1,"days"); // Kamis, 15/Agustus/2019 Pukul 23:21 // Paramter add : "hours", "minutes", "seconds", "months", "years","weeks"
-
Membuat format inline
$contohFormatTanggal = "2019-08-16 23:21"; SimpleDate::createFormat("Do-MMMM-YYYY", $contohFormatTanggal); // 16-Agustus-2019
Membuat Time Ago
// Waktu sekarang di kurangi 1 menit SimpleDate::timeAgo()->add(-1,"minutes"); // 1 menit yang lalu // Tampilakan waktu yang lalu $waktuYangLalu = "2017-01-11 23:21"; SimpleDate::timeAgo($waktuYangLalu);
Tampilkan Waktu Sekarang
Kosongkan tanggal pada paramter, otomatis menggunakan waktu sekarang Contoh:
// default format tanggal SimpleDate::date(); SimpleDate::dayDate(); // add format global SimpleDate::addGlobalFormat([ "displayDay" => "[Hari] dddd [Pukul] HH:mm", "fullDate" => "dddd, Do/MMMM/YYYY [Pukul] HH:mm" ]); // Panggil custom format global SimpleDate::displayDay(); SimpleDate::fullDate(); // Create format inline SimpleDate::createFormat("Do-MMMM-YYYY"); // timeAgo SimpleDate::timeAgo();
Contoh menggunakan fungsi carbon
// Ambil waktu sekarang SimpleDate::now(); // parse time $timeToParse = "2017-01-11 23:21"; SimpleDate::parse($timeToParse)->format("d-m-Y H:i:s"); // 11-01-2017 23:21:00
License
Licensed under The MIT License (MIT).
nim4n/date-format-indonesia 适用场景与选型建议
nim4n/date-format-indonesia 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20.5k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 08 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Simple」 「helper」 「date-format」 「tanggal」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nim4n/date-format-indonesia 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nim4n/date-format-indonesia 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nim4n/date-format-indonesia 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Datetime helpers for timezone handling
A simple library for make Lexer and Parsers to build a language
A simple library that allows transform any kind of data to native php data or whatever
A simple library that uses the hydration pattern to fill objects given different sources of data.
Library with classes to help you do batch.
Micro Active Record library in PHP, support chain calls, events, and relations.
统计信息
- 总下载量: 20.5k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-11