YsUtil
Last updated
Was this helpful?
Last updated
Was this helpful?
is an utilities class for yii framework, also a collection of function snippets that make your web application building job easier. As YeeBase is using YsUtil, it is an integral part of it too.
Install thru composer:
Required PHPMailer
composer package.
Required Html2Text
composer package. Change HTML to plain text string. For example, use in generate alternate text version of email content.
Return array('firstName'=>$firstName, 'lastName'=>$lastName)
by spliting any full name string you insert, e.g.: Allen Tan.
Generate Universal Unique ID which is useful for code
. Internally try to generate thru com_create_guid
. If this PHP function not found, then it fallback to use mt_rand
method.
Turn any text into URL friendly slug format thru series of operations like: trim, lowercase, replace non letter or digits by -, remove unwanted characters and transliterate utf-8.
Generate a random key code at specific length and mode (alphabet only or number only, or both)
$mode:
alphanumeric
alpha
numeric
Convert decimal to base unit integer
Convert base unit integer back to decimal
Convert meter to kilometer
Convert spreadsheet's column number to alphabet. Example:
1 -> A
26 -> Z
27 -> AA
Return true
if a string is MD5 encoded format, else false
.
Return true
if a string is SHA1 encoded format, else false
.
Return true
if a string is in alpha numeric (a-z, A-Z, 0-9 only) format, else false
.
Return true
if a string is a valid email, else false
. Internally using PHP filter_var
FILTER_VALIDATE_EMAIL
Return true
if a string is valid JSON format, else false
. Internally it used json_decode
to check.
take a timestamp from timezone A (preset to GMT) and convert to timezone B
Time elapsed to human readable format (e.g. 2 days 45 min ago).
$interval:
yyyy - Number of full years
q - Number of full quarters
m - Number of full months
y - Difference between day numbers (eg 1st Jan 2004 is "1", the first day. 2nd Feb 2003 is "33". The datediff is "-32".)
d - Number of full days
w - Number of full weekdays
ww - Number of full weeks
h - Number of full hours
n - Number of full minutes
s - Number of full seconds (default)