Date And Timestamp - Study Mode

[#21] Say you want to calculate the date 45 days from the present date which one of the following statement will you use?
Correct Answer

(C) strtotime(“+45 days”)

Explanation

Solution: The strtotime() function and GNU date syntax is used to calculating the date x days from the present date.

[#22] To create an object and set the date to JUNE 22, 2013, which one of the following statement should be executed?
Correct Answer

(D) $date = new DateTime(“22 JUNE 2013”)

Explanation

Solution: The dateTime() method is class constructor. You can set the date either at the time of instantiation or later by using a variety of mutators.

[#23] What will be the output of the following PHP code? <?php echo (checkdate( 4,31,2010 ) ? 'Valid' : 'Invalid' )

?>
Correct Answer

(D) Invalid

Explanation

Solution: April has 30 days and the above date is 31 therefore Invalid is returned.

[#24] If the format is F then which one of the following will be returned?
Correct Answer

(A) Complete text representation of month

Explanation

Solution: Day of month, with leading zero is represented by D

Daylight saving time by I

Day of month, without zeros by j.

[#25] What will the following script output? <?php $time = strtotime ( '2004/01/01' )
echo date ( 'H:i:s', $time )
?>
Correct Answer

(C) 00:i:00