PHPBuilder - UK Date Formating



RSS Twitter
Snippets Calendars Dates

UK Date Formating

by: Steve Darkrahn
|
January 18, 2003

Version: 1.0

Type: Function

Category: Calendars/Dates

License: GNU General Public License

Description: Keeps UK date formating dd/mm/yyyy displayed correctly, and does not output in US format of mm/dd/yyyy. Original idea of using array by swativ but his code still displayed in US format so i did not think that this snippet was classed as a revision.



<?php 

#setlocale (LC_ALL, 'en_UK');
#This was ignored dont know why!!
#and caused me to write this solution

$UKdate = "01/08/2003";
#string stored in UK format in  MySQL database or string variable

$stringArray = explode("/", $UKdate);
#explode the string into the array delimited by /

$newdate = ($stringArray[1]."/".$stringArray[0]."/".$stringArray[2]);
#newdate is set to be first 2 parts of array reversed

$udate = strtotime($newdate);
#use strtotime to convert $newdate

$convertedDate = date("l jS F Y", $udate);
#converted date displays Friday 1st August 2003
#see more date formating on phpbuilder

echo $convertedDate;
#print out result

#Acknowledgements to original script by swativ which
#gave me the idea of using the array, but still output it in US format
?>

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Steve Darkrahn

Comment:



Comment:

(Maximum characters: 1200). You have characters left.