WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Functions that will format a date in either long or short format from a string.
Categories : Date Time, Strings, PHP Update Picture
Michael Stearne
Date : Aug 28th 1998
Grade : 2 of 5 (graded 3 times)
Viewed : 3429
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Michael Stearne
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

/*
Usage: string formatDateS(string);
Input is a string in the format: 19980828
Where the first four digits are the year, the next two are the month, and the
last two are the day.

The function takes the string, breaks it up and reformats in a short
date format, like : 08/28/1998

Usage: string formatDateL(string);
Input is a string in the format: 19980828
Where the first four digits are the year, the next two are the month, and the
last two are the day.

The function takes the string, breaks it up and reformats in a long
date format, like : August 28, 1998


*/

function dateFormatS($date){
                $dy=substr($date,0,4);
                $dm=substr($date,4,2);
                $dd=substr($date,6,2);
                $condate=$dm."/".$dd."/".$dy;
                return $condate;                
}

function dateFormatL($date){
                $dy=substr($date,0,4);
                $dm=substr($date,4,2);
                $dd=substr($date,6,2);
                switch($dm){
                case "01":
                $dm="January";
                break;
                case "02":
                $dm="February";
                break;
                case "03":
                $dm="March";
                break;
                case "04":
                $dm="April";
                break;
                case "05":
                $dm="May";
                break;
                case "06":
                $dm="June";
                break;
                case "07":
                $dm="July";
                break;
                case "08":
                $dm="August";
                break;
                case "09":
                $dm="September";
                break;
                case "10":
                $dm="October";
                break;
                case "11":
                $dm="November";
                break;
                case "12":
                $dm="December";
                break;
                }
                $condate=$dm." ".$dd.", ".$dy;
                return $condate;                
}



Phorum, MySQL, Language, UK date format, MySQL UK Date format
Categories : PHP, Date Time, Strings, MySQL, Databases
Calendar using Date function
Categories : HTML and PHP, PHP, Date Time, Calendar
Avoiding or Detecting high bit characters in a string. Useful when you want to create a valid RSS feed
Categories : PHP, Strings, Unicode, Regexps, Rich Site Summary (RSS)
Select with current month
Categories : PHP, HTML and PHP, Date Time, Arrays
checkdate -- Validate a gregorian date/time
Categories : PHP, PHP Functions, Date Time
explode() and SQL blobs
Categories : General SQL, Strings, PHP, Databases
Using data from a string.
Categories : PHP, Strings, CURL
function textwrap will wrap text to any desired width using <BR>\n as the default line break. Default wrap width is 80 columns.
Categories : Strings, HTML and PHP, PHP
a class that uses microtime() to provide easy calculation of elapsed times
Categories : Date Time, PHP, PHP Classes
Date Validation using JavaScript. Intended to use it as checkdate() from PHP.
Categories : Java Script, Date Time, PHP
I need a trim function/regexp that will trim all " " from the ends of a string.
Categories : Regexps, PHP, Strings
A Timing Class
Categories : PHP, PHP Classes, Date Time
mysql_escape_string
Categories : PHP, MySQL, Databases, Strings
Allows you to parse a deliniated string and put the individual fields in a SELECT option in a form
Categories : HTML, PHP, Strings
Finding the day of the week for a specific date.
Categories : PHP, Databases, MySQL, Date Time