PHP Date Time | PHP Questions
Que. | Which of the following functions do not return a timestamp? 1. time() 2. date() 3. strtotime() 4. localtime() 5. gmmktime() |
|
a. | Option 1 and 5 | |
b. | Option 1 and 4 | |
c. | Option 2 and 4 | |
d. | Option 2 and 4 | |
Answer: Option 2 and 4 |
Que. | What will the following script output? $time = strtotime ('2004/01/01'); echo date ('H:i:s', $time); ?> |
|
a. | 00:i:00 | |
b. | 12:i:00 | |
c. | 12:00:00 | |
d. | 0:00:00 | |
Answer: -1 |
Que. | How many constants does the DateTime class have? | |
a. | 10 | |
b. | 11 | |
c. | 8 | |
d. | 9 | |
Answer: 11 |
Que. | To create an object and set the date to JUNE 22, 2013, which one of the following statement should be executed? | |
a. | $date = new Date(“JUNE 22 2013”) | |
b. | $date = new DateTime(“22 JUNE 2013”) | |
c. | $date = Date(“22 JUNE 2013”) | |
d. | $date = DateTime(“22 JUNE 2013”) | |
Answer: $date = new DateTime(“22 JUNE 2013”) |
Que. | ................Checks a date for numeric validity. | |
a. | check_date | |
b. | Verify_date | |
c. | checkdate | |
d. | verifydate | |
checkdate
Que. | Which function displays the web page’s most recent modification date? | |
a. | lastmod() | |
b. | get_last_mod() | |
c. | getlastmod() | |
d. | last_mod() | |
Answer: getlastmod() |
Que. | What will be the output of the following PHP code? echo (checkdate(4,31,2 ? 'Valid' : 'Invalid'); ?> |
|
a. | Valid | |
b. | Invalid | |
c. | FALSE | |
d. | TRUE | |
Answer: Invalid |
Que. | .......... Returns the time of sunrise for a given day / location. | |
a. | date-sunrise() | |
b. | datesunrise() | |
c. | date.sunrise() | |
d. | date_sunrise() | |
Answer: date_sunrise() |
Que. | Which one of the following function is useful for producing a timestamp based on a given date and time. | |
a. | mktime() | |
b. | time() | |
c. | mtime() | |
d. | mrtime() | |
Answer: mktime() |
Que. | Say you want to calculate the date 45 days from the present date which one of the following statement will you use? | |
a. | totime(“+45”) | |
b. | totime(“+45 days”) | |
c. | strtotime(“-45 days”) | |
d. | strtotime(“+45 days”) | |
strtotime(“+45 days”)
Que. | Among the four PHP DateTimeZone classes given below how many are static? 1. listAbbreviations() 2. getName() 3. getOffset() 4. listIdentifiers() |
|
a. | 3 | |
b. | 4 | |
c. | 1 | |
d. | 2 | |
Answer: 2 |
Que. | What will be the output of the following PHP code? If say date is 22/06/2013. printf( date("t") ) ?> |
|
a. | JUNE | |
b. | 22 | |
c. | 30 | |
d. | 2013 | |
Answer: 30 |
Que. | The getdate() function returns | |
a. | An array | |
b. | An integer | |
c. | A string | |
d. | A floating-point number | |
Answer: boolean |
Que. | Which one of the following format parameter can be used to identify timezone? | |
a. | I | |
b. | T | |
c. | N | |
d. | E | |
Answer: E |
Que. | Which of the following statements can be used to add two months to the existing date? | |
a. | $date->modify(‘2+ months’); | |
b. | $date = modify(‘+2 months’); | |
c. | $date = modify(‘2+ months’); | |
d. | $date->modify(‘+2 months’); | |
$date->modify(‘+2 months’);
Que. | Which of the following statements can be used to set the time zone in individual scripts? | |
a. | date_set_default_timezone(‘Europe/London’); | |
b. | date_default_timezone(‘Europe/London’); | |
c. | date_default_timezone_set(‘Europe/London’); | |
d. | date_set_timezone(‘Europe/London’); | |
Answer: date_default_timezone_set(‘Europe/London’); |
Que. | What will be the output of the following PHP code if date is 24/02/2008? $date = new DateTime(); echo $date->format('l,F,js,Y') ?> |
|
a. | Sunday, 24 02 2008 | |
b. | Sunday, 24th February 2008 | |
c. | Sunday, February 24th 2008 | |
d. | Sunday, 02 24 2008 | |
Answer: Sunday, February 24th 2008 |
Que. | What will be the output of the following code? If say date is 22/06/2013. echo "Today is ".date("F d, Y") ?> |
|
a. | Today is 22 June, 2013 | |
b. | Today is 06-22-2013 | |
c. | Today is 22-06-2013 | |
d. | Today is June 22, 2013 | |
Answer: Today is June 22, 2013 |
Que. | The date() function returns ___ representation of the current date and/or time. | |
a. | Boolean | |
b. | String | |
c. | Integer | |
d. | Float | |
Answer: String |
Que. | Among the four PHP DateTimeZone classes given below how many are nonstatic? 1. _construct() 2. getName() 3. getOffset() 4. getTransitions() |
|
a. | 4 | |
b. | 2 | |
c. | 1 | |
d. | 3 | |
4
Que. | Which of the following is the right way to use the DateTime class? | |
a. | $date = new DateTime(); | |
b. | $date = get_Class(DateTime); | |
c. | $date = new class DateTime(); | |
d. | $date = class DateTime; | |
Answer: $date = new DateTime(); |
Que. | Which method is simply an object-oriented version of date()? | |
a. | DateTime::setTime() | |
b. | DateTime::format() | |
c. | DateTime::modify() | |
d. | DateTime::setDate() | |
Answer: DateTime::format() |
Que. | Which method enables you to calculate whether daylight saving time is in force at a specific date and time? | |
a. | savingTime() | |
b. | getTranitions() | |
c. | getOffset() | |
d. | ISODate() | |
Answer: getTranitions() |
Que. | How many methods does the DateTime class have? | |
a. | 8 | |
b. | 10 | |
c. | 11 | |
d. | 9 | |
Answer: 9 |
Que. | If the format is F then which one of the following will be returned? | |
a. | Complete text representation of month | |
b. | Day of month, without zeros | |
c. | Day of month, with leading zero | |
d. | Daylight saving time | |
Complete text representation of month
Comments