+ Reply to Thread
Results 1 to 6 of 6

Thread: PHP - date() function in French?
      
   

  1. #1
    cosmiclove is offline Sergeant Major
    Join Date
    Oct 2007
    Posts
    90

    Default PHP - date() function in French?

    Hi everyone,

    I added the date() function in my site to display current date, but by default, the date shown is in English. Does anybody know how to modify this date() function in order to display it into another language, notably French?
    Thanks so much in advance.

    Herman

  2. #2
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,061

    Default Re: PHP - date() function in French?

    You would need to change the locale (in the same page where you have the date function). Look at www.php.net
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  3. #3
    cosmiclove is offline Sergeant Major
    Join Date
    Oct 2007
    Posts
    90

    Default Re: PHP - date() function in French?

    Hi Naval,

    Thanks so much!

    I looked at PHP.net and was able to come up with this code for my date:

    PHP Code:
    <?php
    setlocale
    (LC_ALL'fr_FR');

    echo 
    strftime("%A %e %B %Y");
    ?>
    It displays the current time in French, exactly what I wanted. But my concern is to know whether this current time will change daily as it does with date("d/m/Y") function. Will the script update itself tomorrow and any other day? Do they have to work together? If so, I am afraid I don't know how to work with both date() and setlocale() in a same script. Will you help me with that, please?
    A million thank yous in advance!

    Herman

  4. #4
    Watdaflip's Avatar
    Watdaflip is offline Major General
    Join Date
    Sep 2005
    Location
    Cincinnati, Ohio
    Posts
    2,119

    Default Re: PHP - date() function in French?

    It will stay updated with the current day. The one thing you might have to worry about is the difference between the server time and your local time.

    There is a second parameter to the function where you can insert a timestamp.

    You can do something like

    PHP Code:
    echo strftime("%A %e %B %Y"time()+#); 
    Replacing # with some type of offset to adjust the time to your timezone.

    Register/Login Script
    Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

  5. #5
    cosmiclove is offline Sergeant Major
    Join Date
    Oct 2007
    Posts
    90

    Default Re: PHP - date() function in French?

    Hello Watdaflip,

    Thanks for the warning. But what can "#" possibly be in the second parameter of strftime()? My local time zone is the US Central Time (therefore -006 UTC).
    Any idea how I could reformat strftime() based on this factor?
    I am very limited knowledge of PHP, so please go easy on me in your explanations Thanks so much for your help,

    Herman

  6. #6
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,061

    Default Re: PHP - date() function in French?

    # = number in seconds, being that the time difference between your time and the GMT.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49