Quick Search:
 
 PHP Code: String to Date Jump to:  
Category: >> PHP Code >> String to Date  

<< lastnext >>

Snippet Name: String to Date

Description: Convert almost any English textual representation of a date into a timestamp.

Also see:
» Neatly trim a string to a set number o...
» Convert UK Dates To mySQL Format Dates
» Search array elements for a substring
» Add a period at the end of a string if...
» Count capital letters in a string
» Search All Words Of A String In mySQL
» Remove Extra Spaces From A String
» Get Query String with Javascript
» Delete files older than 'X'
» Create string by formatting an amount ...
» Search PL/SQL for a string/ key value
» INSTR (InString)
» SUBSTR (SubString)
» Generate unique strings of random numb...
» String Functions: REVERSE
» String Functions: LENGTH
» String Functions: INSTR
» String Functions: CONCAT
» String Functions: CHAR
» String Functions: INITCAP
» String Functions: LOWER
» String Functions: UPPER
» Sort comma separated string
» String to Date
» Month, Day, Year dropdown boxes
» Calculate date of Easter Sunday
» Define a schedule of holidays
» Calendar for any month any year
» Generate random string
» Add and Subtract dates

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: March 16th, 2009

<?PHP 
 
ECHO STRTOTIME ("now"), "\n"; 
ECHO STRTOTIME ("10 September 2000"), "\n"; 
ECHO STRTOTIME (" 1 day"), "\n"; 
ECHO STRTOTIME (" 1 week"), "\n"; 
ECHO STRTOTIME (" 1 week 2 days 4 hours 2 seconds"), "\n"; 
ECHO STRTOTIME ("next Thursday"), "\n"; 
ECHO STRTOTIME ("last Monday"), "\n"; 
?> 
 
Checking for failure 
<?PHP 
$str = 'Not Good'; 
IF (($timestamp = STRTOTIME($str)) === -1) { 
    ECHO "The string ($str) is bogus"; 
} ELSE { 
    ECHO "$str == ". DATE('l dS of F Y h:i:s A',$timestamp); 
} 
?>
 


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org