|

How to Convert string to Date and DateTime in PHP?

Converting the string to Date and DateTime uses several functions/methods like strtotime(), getDate(). We will see what these functions do.strtotime() – This is basically a function which returns the number of seconds passed since Jan 1, 1970, just like a linux machine timestamp. It returns the number of seconds passed according to the parameter passed to…

|

How do I make a redirect in PHP?

How do I make a redirect in PHP? Basic answer You can use the header() function to send a new HTTP header, but this must be sent to the browser before any HTML or text (so before the <!DOCTYPE …> declaration, for example). Important details die() or exit() Why you should use die() or exit(): The Daily WTF Absolute or relative URL Since June 2014…

|

How can I sort arrays and data in PHP?

Sort arrays and data in PHP Basic one dimensional arrays Applicable sort functions: sort rsort asort arsort natsort natcasesort ksort krsort The difference between those is merely whether key-value associations are kept (the “a” functions), whether it sorts low-to-high or reverse (“r“), whether it sorts values or keys (“k“) and how it compares values (“nat”…