Script help! Date stamp in Day/Month/Year format (script provided!)

Discussion in 'PHP' started by Dreamconcepts, Sep 21, 2010.

  1. #1
    Example. September 22, 2010 = 22/09/2010

    Anyone know how to do it?

    Here's the current script being used:

    <script language="Javascript">


    // Array of day names
    var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday",
    "Thursday","Friday","Saturday");

    // Array of month Names
    var monthNames = new Array(
    "January","February","March","April","May","June","July",
    "August","September","October","November","December");

    var now = new Date();
    now.setDate(now.getDate());
    document.write(monthNames[now.getMonth()] + " " +
    (now.getDate()) + ", " + now.getFullYear());

    // -->
    </script>
     
    Dreamconcepts, Sep 21, 2010 IP
  2. krishmk

    krishmk Well-Known Member

    Messages:
    1,376
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    185
    #2
    Here is the php code

    <?php
    $time = time();
    $date = date ('d/m/Y', $time);
    echo ("$date");
    ?>
    PHP:
     
    krishmk, Sep 21, 2010 IP
  3. Dreamconcepts

    Dreamconcepts Peon

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    How would this be used inside of an index.html?

    Can you make this into script form?

    Thank you!
     
    Dreamconcepts, Sep 21, 2010 IP
  4. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #4
    Change the file extension from .html to .php, and then simply place the following line/s of code where you wish to display the date:

    <?php
    echo date('d/m/Y');
    ?>
    PHP:
     
    danx10, Sep 22, 2010 IP
  5. Dreamconcepts

    Dreamconcepts Peon

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Can this be done with a .html extension? If so, how?

    Thanks for everyone's HELP!
     
    Dreamconcepts, Sep 22, 2010 IP
  6. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #6
    Well you can try something like the following in JavaScript.

    <script language="javascript"> 
    var d = new Date();
    document.write(d.getDay() + '/' + d.getMonth() + '/' + d.getFullYear());
    </script>
    Code (markup):
     
    danx10, Sep 22, 2010 IP
  7. Dreamconcepts

    Dreamconcepts Peon

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hey Dan,

    I tried implementing your script, but it gathers the wrong date. The year is right though. How do you tweak it so that it works in the format off day/month/year?

    Thanks!
     
    Dreamconcepts, Sep 22, 2010 IP
  8. riteshsanap

    riteshsanap Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    3
    Trophy Points:
    168
    #8
    The Date are given through local machines time so to get the time according to your country or area you need to set time zone GMT
     
    riteshsanap, Sep 22, 2010 IP
  9. riteshsanap

    riteshsanap Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    3
    Trophy Points:
    168
    #9
    I think this might help you thoroughly

    http://php.net/manual/en/book.datetime.php
    Code (markup):
     
    riteshsanap, Sep 22, 2010 IP
  10. Dreamconcepts

    Dreamconcepts Peon

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Ok, the time zone is Sao Paulo, Brazil. Can you help?
     
    Dreamconcepts, Sep 22, 2010 IP
  11. riteshsanap

    riteshsanap Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    3
    Trophy Points:
    168
    #11
    the time zone for Sao Paulo , Brazil is UTC/GMT 3:00
     
    riteshsanap, Sep 22, 2010 IP
  12. Dreamconcepts

    Dreamconcepts Peon

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    How can that be implemented to a web page?

    Thanks!
     
    Dreamconcepts, Sep 22, 2010 IP
  13. riteshsanap

    riteshsanap Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    3
    Trophy Points:
    168
    #13
    this can be done by adding this line of script

    <?php date_default_timezone_set ("Asia/Calcutta"); ?>
    PHP:
    Change Asia/Calcutta with your area like Brazil/sao paulo or you can use the UTC/GMT that i have given you
     
    riteshsanap, Sep 22, 2010 IP
  14. Dreamconcepts

    Dreamconcepts Peon

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    I'm sorry to hassle you...I'm not a good coder.

    Is it possible for you to make it for me?

    Thank you so much Ritesh!
     
    Dreamconcepts, Sep 22, 2010 IP
  15. riteshsanap

    riteshsanap Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    3
    Trophy Points:
    168
    #15
    So heres your code
    <?php date_default_timezone_set ("UTC-3"); ?>
    PHP:
    and me also not good in php :D just i love to help thats why .

    if you like my work please Rep me :D
     
    riteshsanap, Sep 22, 2010 IP
  16. Dreamconcepts

    Dreamconcepts Peon

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Oops...can you somehow change it to html?
     
    Dreamconcepts, Sep 22, 2010 IP
  17. riteshsanap

    riteshsanap Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    3
    Trophy Points:
    168
    #17
    what do you mean?
     
    riteshsanap, Sep 22, 2010 IP
  18. riteshsanap

    riteshsanap Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    3
    Trophy Points:
    168
    #18
    can you please elaborate what you exactly need
     
    riteshsanap, Sep 22, 2010 IP
  19. riteshsanap

    riteshsanap Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    3
    Trophy Points:
    168
    #19
    Ok now i understood you want to use the same above script but you wanted to add / after very date right ?
     
    riteshsanap, Sep 22, 2010 IP
  20. Dreamconcepts

    Dreamconcepts Peon

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #20
    I need it for an html landing page. Also need the format to match date/month/year.

    Thanks!
     
    Dreamconcepts, Sep 22, 2010 IP