![]() php > print date("m/d/y h:i:s a", $unixTime) Of course, you can use other specifiers to define your own custom formats. The “r” formatting string returns the time formatted as specified by RFC 2822. If the optional timestamp is not provided, the value of time() is used. date() is used to format Unix timestamps into a human readable string, and takes a formatting argument and an optional time argument. Unix time can be easily formatted into just about any string that a human would want to read. It takes an optional Unix timestamp argument, but defaults to the value of time() if one isn’t provided. If you need an array representation of the Unix time, use the getdate() function. To illustrate this, I will use the PHP interactive CLI shell. Time() takes no arguments and returns the number of seconds since the Unix epoch. I’ll talk more on this later, but let’s ignore time zone issues for now and look at some time functions. All other time zones in the world are expressed as a positive or negative offsets from this time. Treating time in UTC and Unix time will make your life easier when you need to deal with time zones. UTC, also know by its full name Coordinated Universal Time, also referred to as GMT, and sometimes Zulu time, is the time at 0-degrees longitude. ![]() If you’re interested in a complete history of Unix time, check out the Unix time article on Wikipedia. Time is represented as an offset in the amount of seconds that have ticked away since midnight of January 1, 1970, UTC. Year for the week where Monday is the first day of the week.Much of this article will work with Unix time, or POSIX or epoch time as it is otherwise known. Year for the week where Sunday is the first day of the week. ![]() Weekday name in full (Sunday to Saturday)ĭay of the week where Sunday=0 and Saturday=6 Week where Monday is the first day of the week (01 to 53). Week where Sunday is the first day of the week (01 to 53). Week where Monday is the first day of the week (00 to 53) Week where Sunday is the first day of the week (00 to 53) Time in 12 hour AM or PM format (hh:mm:ss AM/PM) Can be one or aĭay of the month as a numeric value, followed by suffix (1st, 2nd, 3rd,ĭay of the month as a numeric value (01 to 31)ĭay of the month as a numeric value (0 to 31) ![]() String Functions: ASCII CHAR_LENGTH CHARACTER_LENGTH CONCAT CONCAT_WS FIELD FIND_IN_SET FORMAT INSERT INSTR LCASE LEFT LENGTH LOCATE LOWER LPAD LTRIM MID POSITION REPEAT REPLACE REVERSE RIGHT RPAD RTRIM SPACE STRCMP SUBSTR SUBSTRING SUBSTRING_INDEX TRIM UCASE UPPER Numeric Functions: ABS ACOS ASIN ATAN ATAN2 AVG CEIL CEILING COS COT COUNT DEGREES DIV EXP FLOOR GREATEST LEAST LN LOG LOG10 LOG2 MAX MIN MOD PI POW POWER RADIANS RAND ROUND SIGN SIN SQRT SUM TAN TRUNCATE Date Functions: ADDDATE ADDTIME CURDATE CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURTIME DATE DATEDIFF DATE_ADD DATE_FORMAT DATE_SUB DAY DAYNAME DAYOFMONTH DAYOFWEEK DAYOFYEAR EXTRACT FROM_DAYS HOUR LAST_DAY LOCALTIME LOCALTIMESTAMP MAKEDATE MAKETIME MICROSECOND MINUTE MONTH MONTHNAME NOW PERIOD_ADD PERIOD_DIFF QUARTER SECOND SEC_TO_TIME STR_TO_DATE SUBDATE SUBTIME SYSDATE TIME TIME_FORMAT TIME_TO_SEC TIMEDIFF TIMESTAMP TO_DAYS WEEK WEEKDAY WEEKOFYEAR YEAR YEARWEEK Advanced Functions: BIN BINARY CASE CAST COALESCE CONNECTION_ID CONV CONVERT CURRENT_USER DATABASE IF IFNULL ISNULL LAST_INSERT_ID NULLIF SESSION_USER SYSTEM_USER USER VERSION SQL Server FunctionsĭATE_FORMAT( date, format) Parameter Values Parameter ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |