The ‘strtotime()’ function parses an English textual datetime into a Unix timestamp and it is quite powerful with relative time format.
Example:
### To get sunday timestamp of current week strtotime('sunday this week'); ### To get monday timestamp of current week strtotime('monday this week');
Related Posts
- How to add and subtracting years in current date using PHP date() function
PHP date() function formats a local date and time, and returns the formatted date string. In this article, I described the simple process about how to add and subtract number of years from the current date using default PHP date() function. Add number of years in current date: (Example: adding 5 years)…
-
Generating Random String Using PHP
Generating random strings with custom specified length is most required functionality in every project. In this article, I described the easiest way to generate custom length random string. PHP program for Random String Generate: <?php /* * Function to generate random string * Default length 30 character */ function generateRandomString($length…
- How to add and subtracting days using php date function
PHP date() function formats a local date and time, and returns the formatted date string. In this article, I described the simple process about how to add and subtract number of days from current date using default PHP date() function. Add number of days in current date: php strtotime add…
-
PHP: Create empty object - new stdClass,var_dump
stdClass is the default PHP object. stdClass has no properties, methods or parent. It does not support magic methods, and implements no interfaces. Standard way to create an "empty" object is: <?php $input_object = new stdClass(); var_dump($input_object); ?> Result for new stdClass(): object(stdClass)#1 (0) { } But, with PHP Version…
- How to add and subtracting weeks using php date() function
PHP date() function formats a local date and time, and returns the formatted date string. In this article, I described the simple process about how to add and subtract number of weeks from current date using default PHP date() function. Add number of weeks in current date: (Example: adding 5 weeks) <?php…
- Get the last element of an array in PHP – end()
The end() function is an inbuilt function in PHP Programming. The purpose of this function is to find the last element of the given input array. The end() function changes the internal pointer of an array to the last element and returns the value of the last element. end() PHP…
-
PHP: How to copy all files from one directory to another
I will guide you to copy all files & sub directories of the directory to another directory using PHP copy() function. There are many other functions used to copy the content of one directory to another. copy() Functionopendir() Functionis_dir() Functionscandir( ) Functionreaddir() Function PHP code for copy multiple files from…
- PHP Cheat Sheet
PHP code is usually processed on a web server by a PHP interpreter implemented as a module, a daemon or as a Common Gateway Interface (CGI) executable. On a web server, the result of the interpreted and executed PHP code — which may be any type of data, such as…
- How to add and subtracting months using php date() function
PHP date() function formats a local date & time, it returns the formatted string formatted date. In this article, I described the simple process about how to add and subtract number of months from the current date using default PHP date() function. Add number of months in current date: (Example:…
-
PHP: Convert JSON String to Array / Object using json_decode
How to convert JSON String to Array / Object using json_decode? json_decode is inbuilt function in PHP. It will take a JSON string and converts it into a PHP array or object depends on arguments. Live demo: https://www.gtechhub.com/json-decode-online Convert JSON String to PHP Object: <?php $json_input = '{"array_key_1":"array_value_1","array_key_2":"array_value_2", "array_key_3":"array_value_3","array_key_4":"array_value_4","array_key_5":"array_value_5"}'; $json_result…