PHP Date/Time


  1. What will be the output of the following PHP code if date is 15/03/2019?
    <?php
    $date = new DateTime();
    echo $date->format('l,F,js,Y')
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    The format() method displays the date in same way as standard date function().


  1. Which of the following statements can be used to set the time zone in individual scripts?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    You can also use ini_set(‘date.timezone’, ‘Europe/London’);.



  1. Among the four PHP DateTimeZone classes given below how many are static?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    listAbbreviations() and listIdentifiers() are static methods.


  1. Among the four PHP DateTimeZone classes given below how many are non static?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    All of the given methods are non static.



  1. Which of the following statements can be used to add two months to the existing date?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    To change the date stored by a DateTime object after it has been created, you use DateTime::modify() with a natural language expression.