Category: >> PHP Code >> Easy date manipulation Bookmark and Share

<< lastnext >>

Snippet Name: Easy date manipulation

Description: Many times you may need to change a date from one format to another. For example, you may need to change "05-21-2010" (month, day, year) to the more standard "year month day" format. Here's an easy way to do that.

Also see:
» Calculate days between any two dat...
» Easily Change Text To Lowercase
» Format money as millions, billions...
» Convert UK Dates To mySQL Format D...
» Calculate the difference between t...
» TABLESPACE: Change UNDO tablespace
» Delete files older than 'X'
» RMAN: Format Directives
» USER - connection information
» USER - User Information 2
» USER Information
» SQL*Plus formatting
» Create string by formatting an amo...
» List security related profile info...
» Currency display formatting functi...
» Nicely Format File Size
» String to Date
» Month, Day, Year dropdown boxes
» Calculate date of Easter Sunday
» Define a schedule of holidays
» Calendar for any month any year
» Add and Subtract dates
» Basic PHP Calendar
» Change table type
» Format numbers to two decimal plac...
» Convert 12 to 24 hour time and vic...
» What Season Is It?
» Output as Word Doc format
» Change text box height
» Delete by date

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: December 27th, 2010

// put the date into a variable 
$date = "02-21-2010"; 
// change the date to a UNIX timestamp
$timestamp = strtotime($date); 
// transform the timestamp back to a date
// this will return "2010-02-21"
$date = date("Y-m-d",$timestamp); 
// this will return "February 21st, 2010"
$date = date("F jS, Y",$timestamp); 
// this will return "Feb 21, 2010"
$date = date("M j, Y",$timestamp); 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© | users online: 4