How to display Indian Date in text box (php form)

Discussion in 'PHP' started by nkurahatti, Dec 3, 2007.

  1. #1
    Dear All,

    I am new to PHP programming. I have very little knowledge in php.

    I want to know how to display current Indian date in textbox (php form)
    Date should load on form load event.

    I used following date function
    <?php echo date("d/m/Y");?>

    The problem is server is in USA
    So textbox showing US date!

    But I need Indian date
    Date format (dd/mm/yyyy)

    Thanks and regards
    Narayan K
    India
     
    nkurahatti, Dec 3, 2007 IP
  2. zyml

    zyml Peon

    Messages:
    66
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You'll probably have to add the difference in hours between the time in US and India to the current time. Use date() to get the current hour and add the difference, then use the mktime() function to generate the date in Indian timezone.
     
    zyml, Dec 3, 2007 IP
  3. Evoleto

    Evoleto Well-Known Member

    Messages:
    253
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #3
    Try the following code:
    
    echo date( "d/m/Y" );
    
    PHP:
     
    Evoleto, Dec 3, 2007 IP
  4. anantk

    anantk Active Member

    Messages:
    121
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #4
    if your server is on USA Central time, you'll have to set the code up to add 11.5 hrs to the time to match with IST
     
    anantk, Dec 4, 2007 IP