1. Go to this page and download the library: Download mojahed/converts library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mojahed / converts example snippets
use Mojahed\Convert;
$c = Convert::setPath('/usr/local/bin/MdsConvert');
// Digit
$c->enToBn('12,345'); // ১২,৩৪৫
$c->bnToEn('১২,৩৪৫'); // 12,345
// Numbers
$c->stringToInt('12.99'); // 12
$c->stringToFloat('12.13'); // 12.13
$c->round('43.5435', 2); // 43.54
$c->formatNum('1234567.8', 2); // 1,234,567.80
$c->abs('-9.5'); // 9.5
// Math
$c->percent('20', '500'); // 100.00
$c->percentOf('100', '500'); // 20.00%
$c->clamp('15', '0', '10'); // 10
$c->decToHex('255'); // ff
$c->hexToDec('ff'); // 255
// Strings
$c->slug('Hello World! 2024'); // hello-world-2024
$c->camelToSnake('myVar'); // my_var
$c->snakeToCamel('my_var'); // myVar
$c->truncate('Hello World', 5); // Hello...
// Date & Time (default = system timezone)
$c->humanToUnix('2024-05-18 05:20:00'); // 1716009600
$c->unixToHuman('1716009600'); // 2024-05-18 05:20:00 (+06)
$c->now(); // current unix timestamp
$c->nowHuman(); // current date/time
// Date with explicit timezone
$c->tz('Asia/Dhaka')->unixToHuman('1716009600');
$c->tz('America/New_York')->nowHuman();
$c->tz('Asia/Dhaka')->dateFormat('2024-05-18', 'DD/MM/YYYY TZ');
// Color
$c->hexToRgb('#ff6600'); // 255,102,0
$c->rgbToHex('255,102,0'); // #ff6600
$c->rgbToHsl('255,102,0'); // 24,100%,50%
$c->rgbToCss('255,102,0'); // rgb(255, 102, 0)
// Units
$c->cToF('100'); // 212.00
$c->kgToLb('70'); // 154.3234
$c->bytesTo('1048576', 'MB'); // 1.0000 MB
// Number to Words
$c->numToWords('100'); // one hundred
$c->numToWords('12345'); // twelve thousand three hundred forty-five
$c->numToWords('-999'); // negative nine hundred ninety-nine
$c->numToBnWords('১০০'); // একশত
$c->numToBnWords('১২৩৪৫'); // বারো হাজার তিনশত পঁয়তাল্লিশ
$c->numToBnWords('10000000'); // এক কোটি
// Encoding
$c->b64Encode('hello'); // aGVsbG8=
$c->b64Decode('aGVsbG8='); // hello
$c->sha256('hello'); // 2cf24dba...
// JSON
$c->jsonPretty('{"a":1}');
$c->jsonMinify('{ "a": 1 }');
$c->jsonValidate('{"ok":true}'); // valid
// UUID
$c->uuid(); // e.g. 806df7fe-c4e5-4f13-bb01-fc4ebda9ded2
$c->isUuid('550e8400-e29b-41d4-a716-446655440000'); // valid