Php Date And Timestamp(Engineering > Computer Science And Engineering > Php ) Questions and Answers

Question 1. What will be the output of the following PHP code?echo (checkdate(4,31,2010) ? 'Valid' : 'Invalid');
  1.    FALSE
  2.    TRUE
  3.    Valid
  4.    Invalid
Explanation:-
Answer: Option D. -> Invalid

Question 2. What will be the output of the following code?If say date is 22/06/2013.echo "Today is ".date("F d, Y")
  1.    Today is 22-06-2013
  2.    Today is 22 June, 2013
  3.    Today is 06-22-2013
  4.    Today is June 22, 2013
Explanation:-
Answer: Option D. -> Today is June 22, 2013

Question 3. Which one of the following format parameter can be used to identify timezone?
  1.    N
  2.    E
  3.    I
  4.    T
Explanation:-
Answer: Option B. -> E

Question 4. If the format is F then which one of the following will be returned?
  1.    Daylight saving time
  2.    Complete text representation of month
  3.    Day of month, with leading zero
  4.    Day of month, without zeros
Explanation:-
Answer: Option B. -> Complete text representation of month

Question 5. The date() function returns ___ representation of the current date and/or time.
  1.    Float
  2.    Integer
  3.    String
  4.    Boolean
Explanation:-
Answer: Option C. -> String

Question 6. Which one of the following function is useful for producing a timestamp based on a given date and time.
  1.    mrtime()
  2.    mtime()
  3.    time()
  4.    mktime()
Explanation:-
Answer: Option D. -> mktime()

Question 7. Say you want to calculate the date 45 days from the present date which one of the following statement will you use?
  1.    strtotime(“+45 days”)
  2.    strtotime(“-45 days”)
  3.    totime(“+45”)
  4.    totime(“+45 days”)
Explanation:-
Answer: Option A. -> strtotime(“+45 days”)

Question 8. Which function displays the web page’s most recent modification date?
  1.    get_last_mod()
  2.    lastmod()
  3.    getlastmod()
  4.    last_mod()
Explanation:-
Answer: Option C. -> getlastmod()

Question 9. To create an object and set the date to JUNE 22, 2013, which one of the following statement should be executed?
  1.    $date = DateTime(“22 JUNE 2013”)
  2.    $date = new Date(“JUNE 22 2013”)
  3.    $date = Date(“22 JUNE 2013”)
  4.    $date = new DateTime(“22 JUNE 2013”)
Explanation:-
Answer: Option D. -> $date = new DateTime(“22 JUNE 2013”)

Question 10. What will be the output of the following PHP code?If say date is 22/06/2013.printf( date("t") )
  1.    2013
  2.    30
  3.    22
  4.    JUNE
Explanation:-
Answer: Option B. -> 30