Skip to content

πŸ“…βœ¨ A TypeScript ES-Module library with a magical date function πŸͺ„πŸŒŸ! Just like PHP's date function, it also offers formateDate πŸ“† & formatDatetime ⏰ utilities. Simplify date formatting in your projects! βš™οΈπŸš€

License

Notifications You must be signed in to change notification settings

AlcyZ/sdx-php-date

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“…βœ¨ sdx-php-date TypeScript Library πŸͺ„πŸŒŸ

Simplify date handling with sdx-php-date! This TypeScript ES-Module library brings the power of PHP's date function to your JavaScript projects, with added functionalities. ✨

πŸš€ Features

  • date(): Format dates just like PHP's date function, with optional timestamp support. ⏰
  • formatDate(): Easily format JS Date objects with custom formats. πŸ“†
  • formatDatetime(): Format datetime strings effortlessly, following PHP's date function style. β°πŸ“†

πŸ“ Usage

import { date, formatDate, formatDatetime } from 'sdx-php-date';

// Format current date
const formattedDate = date('Y-m-d'); // Output: '2023-08-02'

// Format specific timestamp
const formattedTimestamp = date('H:i', 1627915200); // Output: '00:00'

// Format JS Date object
const jsDate = new Date('2023-08-02T12:34:56');
const formattedJSDate = formatDate('l, F jS Y', jsDate); // Output: 'Wednesday, August 2nd 2023'

// Format datetime string
const datetimeString = '2023-08-02 12:34:56';
const formattedDatetime = formatDatetime('d/m/Y h:i A', datetimeString); // Output: '02/08/2023 12:34 PM'

βš™οΈ Installation

To install sdx-php-date, use npm:

npm install sdx-php-date

πŸ› οΈ TypeScript Configuration

Make sure your TypeScript configuration includes:

{
  "compilerOptions": {
    "module": "ESNext",
    "target": "ES5",
    "strict": true,
    "moduleResolution": "Node",
    "sourceMap": true,
    "noEmit": true,
    "lib": ["es2017"]
  },
  "files": [
    "date.ts"
  ]
}

🎩 Contribute

Contributions are welcome! If you encounter any issues or have suggestions, feel free to open an issue or submit a pull request. Let's make date handling magical together! πŸͺ„βœ¨

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

Enjoy using sdx-php-date and have fun coding! πŸš€πŸ’»

About

πŸ“…βœ¨ A TypeScript ES-Module library with a magical date function πŸͺ„πŸŒŸ! Just like PHP's date function, it also offers formateDate πŸ“† & formatDatetime ⏰ utilities. Simplify date formatting in your projects! βš™οΈπŸš€

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •