Submit Your Article Forum Rules

Results 1 to 3 of 3

Thread: British Date Format Help (PHP)

  1. #1

    British Date Format Help (PHP)

    I have installed the Ultra Apps portal system.
    http://www.ultraapps.com/freecommunitywebportal.html

    My site is:

    http://ukasian.co.uk


    I have difficulty in changing the date formats to British (dd/mm/yy).

    The code I think I need tol change is in common.php:

    function now()
    {
    return date("Y-m-d G:i:s");
    }

    function vdate($ldate)
    {
    $ldate = str_replace(":","-",$ldate);
    $ldate = str_replace(" ","-",$ldate);
    list ($year, $month, $day, $hour, $minute) = explode("-", $ldate);
    if ($newdate = mktime ($hour, $minute, 0, $month, $day, $year)) {
    if (@date("H-i", $newdate) == "00-00")
    return @date("m/d/y", $newdate);
    else
    return @date("m/d/y h:i A", $newdate);
    }
    }

    function sdate($ldate)
    {
    list ($year, $month, $day, $hour, $minute) = explode("-", $ldate);
    $newdate = mktime (0, 0, 0, $month, $day, $year);
    return date("m/d/y", $newdate);
    }

    function datetodb($edate)
    {
    return date("Y-m-d H:i:s",strtotime($edate));
    }


    I have tried the simple things like changing m/d/y to d/m/y... This causes problems in save and retrive from database (changes numbers around).

    The database is in MYSQL, Field is a standard DateTime.

    Any help would be much appriciated.
    Our Global NPN Team Is Growing FAST Worldwide!

  2. #2
    Junior Member
    Join Date
    Oct 2004
    Posts
    18

    Re: British Date Format Help (PHP)

    Insert date in database in y-m-d format through php. You can select(retrieve) date using date function in mySQL in your format through sql query. check mySQL Manual to do this.

    <Mod Edit paulhiles - removed irrelevant promotional links >http://www.indastro.com[/url]

  3. #3
    Senior Member mushroom's Avatar
    Join Date
    Feb 2004
    Posts
    286
    To start with "now();" is a standard function and you should not try to redefine it.
    Datetime is mysql is stored "YYYY-MM-DD hh:mm:ss"
    But if you use timestamps in mysql you have built in php function for formating your display "string_date(string format,integer timestamp);"
    Code:
    string_date("d/m/Y h:i A",$timestamp_var);
    Irony: That for most people the most "trusted" web site on the planet is for a company the has been convicted of criminal activity.

    Both Security and SuSe start with "S". www.eemam.com

Similar Threads

  1. ASP Date Format
    By morestar in forum Web Programming Discussion Forum
    Replies: 2
    Last Post: 12-14-2009, 11:45 AM
  2. MySQL PHP Date Format
    By richkoi in forum Database Discussion Forum
    Replies: 9
    Last Post: 09-30-2005, 01:05 AM
  3. British Date Fromat Help (PHP)
    By bossmode in forum Web Programming Discussion Forum
    Replies: 1
    Last Post: 10-28-2004, 12:58 PM
  4. It's great to be British
    By carbonize in forum The Castle Breakroom (General: Any Topic)
    Replies: 2
    Last Post: 03-10-2004, 03:36 PM
  5. PHP to mySQL date format conversion
    By amorphic8 in forum Web Programming Discussion Forum
    Replies: 2
    Last Post: 01-19-2004, 12:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •