PHP Date and Time Questions and Answers with Useful Programs

PHP Date and Time Multiple Choice Questions and Answers with Useful Programs and Explanations.
1. How many php methods are available in DateTime Class?
[A] 12
[B] 6
[C] 3
[D] 9
2. How many constants does the DateTime class have in php 5.6?
[A] 8
[B] 9
[C] 10
[D] 11
3. Which one of the following format parameter is correct to get timezone in date() function?
[A] F
[B] T
[C] e
[D] D
4. Which one of the following format parameter can be used to get seconds with leading zero?
[A] S
[B] d
[C] Y
[D] s
5. How we can set default timezone for our PHP application or website?
[A] set_time_zone('UTC');
[B] default_date_timezone_set('UTC');
[C] date_default_timezone_set('UTC');
[D] default_timezone('UTC')
6. What will be the output of following PHP snippet?
      echo  date('\i\t \i\s \t\h\e jS \d\a\y.');

[A] \i\t \i\s \t\h\e jS \d\a\y.
[B] it is the 10th day.
[C] \i\t \i\s \t\h\e 10th \d\a\y.
[D] it is the 10S day.
7. Which of the following functions do not return a timestamp?
[A] time()
[B] date()
[C] strtotime()
[D] localtime()
[E] gmmktime()
8. ................ Formats a local time or date according to locale settings.

[A] strftime
[B] strgtime
[C] strhtime
[D] stritime
9. The ......... function parses an English textual date or time into a Unix timestamp

[A] strtodate()
[B] stroftime()
[C] strtotime()
[D] str_to_time()
10. What would happen if the following script were run on a Windows server set to Moscow, Russia’s time zone?


echo gmmktime(0, 0, 0, 1, 1, 1970);

[A] It would output the number 0
[B] It would output the number -1
[C] It would output the number 1
[D] It would raise an error
[E] It would output nothing
Are these questions helpful for you?

PHP Date and Time Programs/Functions

Comments: (Your feedback is valuable to us)

Davinder Singh 3 years ago Reply

Thanks admin ... i really like this... please share more questions

KBC Questions and Answers