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
Submit Site
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 : Show the Date in any Language - This function allows you to define how to show the month/day name in the format that you want, in a diffrent language than the server's language.
Categories : PHP, Date Time, Arrays Click here to Update Your Picture
Wilson Aquino
Date : Dec 20th 2007
Grade : 3 of 5 (graded 2 times)
Viewed : 1369
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Wilson Aquino
Action : Grade This Code Example
Tools : My Examples List

 
Like this code?
Show the author your appreciation.
Submit your own code examples 
 

If the server is english and you want to display it in spanish, thats impossible, so you define the names array($lang['Months'], $lang['Days'] whichever you need or both) then:

titles have to be small cap
<?php
$lang
['Days'] = array('sunday' => 'Domingo', 'monday' => 'Lunes'...);
$lang['Months'] = array('january' => 'Enero', 'february' => 'Febrero'...);
echo
dater('D F, Y');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Custom Language Date</title>
</head>

<body>
<?php
define
('DEFAULT_TIME', time());
////->
$lang['Days'] = array('sunday' => 'Sunday', 'monday' => 'Monday', 'tuesday' => 'Tuesday', 'wednesday' => 'Wednesday', 'thuesday' => 'Thuesday', 'friday' => 'Friday', 'saturday' => 'Saturday', 'sun' => 'Sun', 'mon' => 'Mon', 'tue' => 'Tue', 'wed' => 'Wed', 'thu' => 'Thu', 'fri' => 'Fri', 'sat' => 'Sat');
$lang['Months'] = array('january' => 'January', 'february' => 'February', 'march' => 'March', 'april' => 'April', 'may' => 'May', 'june' => 'June', 'july' => 'July', 'august' => 'August', 'september' => 'September', 'october' => 'October', 'november' => 'November', 'december' => 'December', 'jan' => 'Jan', 'feb' => 'Feb', 'mar' => 'Mar', 'apr' => 'Apr', 'jun' => 'Jun', 'jul' => 'Jul', 'aug' => 'Aug', 'sep' => 'Sep', 'oct' => 'Oct', 'nov' => 'Nov', 'dec' => 'Dec');
////->
function dater($format, $time = DEFAULT_TIME){
    global
$lang;
    if(empty(
$lang)){ $lang = get_Lang(); }
    if(empty(
$format)){ return; }
   
$date = '';
   
///->
   
for($i = 0; $i < strlen($format); $i++){
        switch(
$format[$i]){
            case
'D': // Day, Short Name
               
$D = strtolower(date('D', $time));
               
$date .= (isset($lang['Days'][$D]) ? $lang['Days'][$D] : date('D', $time)); break;
            case
'l': // Day, Full Name
               
$l = strtolower(date('l', $time));
               
$date .= (isset($lang['Days'][$l]) ? $lang['Days'][$l] : date('l', $time)); break;
            case
'M': // Month, Short Name
               
$M = strtolower(date('M', $time));
               
$date .= (isset($lang['Months'][$M]) ? $lang['Months'][$M] : date('M', $time)); break;
            case
'F': // Month, Full Name
               
$F = strtolower(date('F', $time));
               
$date .= (isset($lang['Months'][$F]) ? $lang['Months'][$F] : date('F', $time)); break;
            case
'P': // I try to make it but is originaly from PHP >= 5.1.3
               
$P = date('O', $time);
               
$date .= substr($P, 0, 3).':'.substr($P, 3, 2); break;
            case
'r': // Full Time/Date
               
$D = dater('D', $time);
               
$M = dater('M', $time);
               
$date .= $D.', '.date('d', $time).' '.$M.' '.date('Y', $time).' '.date('H', $time).':'.date('i', $time).':'.date('s', $time).' '.date('O', $time);
                break;
            default:
$date .= date($format[$i], $time); break;
        }
    }
   
///->
   
return $date;
}
echo
dater('d/F/Y');
?>
</body>
</html>



enhanced date picker with jcript checking for a dynamic date input
Categories : PHP, Java Script, Date Time, Calendar, Arrays
Simple conversion functions to change MySQL dates to arrays, arrays to MySQL dates.
Categories : PHP, Arrays, Date Time, Databases, MySQL
Function that returns an array with the 7 dates of the week that belong to the supplied date.
Categories : PHP, Date Time, Arrays
Select with current month
Categories : PHP, HTML and PHP, Date Time, Arrays
Tag content retrieval from websites with preg_match
Categories : PHP, Regexps, Arrays, HTML and PHP
Array values from javascript to php
Categories : PHP, Java Script, Arrays
A Timing Class
Categories : PHP, PHP Classes, Date Time
clearing variables in php3
Categories : Variables, Arrays, PHP
Weighted Random - Random Scripts usually chose one out of each item, and each item have an equal chance to be chosen. But what if you want an item to be chosed more frequently than other?
Categories : PHP, Math., Arrays
Finding the day of the week for a specific date.
Categories : PHP, Databases, MySQL, Date Time
Display list of files within current and subdirectories (recursively) showing each file as an anchored link and each directory as a category header.
Categories : Filesystem, Directories, Arrays, PHP
A wrapper function to format dates coming from a databases with the same syntax as PHP's date() function.
Categories : Date Time, Databases, PHP
pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP, Date Time, Calendar, PHP Classes
Dump the contents of a PHP variable in html format with a recursive list of subfolders and files from a given root directory.
Categories : PHP, Directories, Variables, Arrays
Array Insertion
Categories : PHP, PHP Classes, Arrays