1. time() – To get
current date and time information as timestamp value. Timestamp is total number
of seconds from 1970 Jan 1 12:00 am
Example –
<?php
echo time();
?>
Output –
1485861862
2. date() – This function
converts timestamp value as date, month and year format string.
Example –
<?php
echo date('d/m/y',time());
?>
Output –
31/01/17
Characters supported by date() –
- · d – 2-digit date number with leading 0.
- · j – A number without leading 0.
- · D – 3-character day name (Mon, Tue etc).
- · l – Full day name.
- · m – Month number with leading 0.
- · n – Month number without leading 0.
- · M – Month name with 3-character (Jan, Feb etc).
- · F – Full month name.
- · y – 2-digit year number.
- · Y – 4-digit year number.
- · h – 12-hour format with leading 0.
- · H – 24-hour format with leading 0.
- · g – 12-hour format without 0.
- · G – 24-hour format without 0.
- · i – Minutes.
- · s – Seconds.
- · a – Lowercase am/pm.
- · A – Uppercase AM/PM.
- · w – Day number in a week from 0 to 6.
- · N – Day number in a week from 1-7.
- · W – Number of completed weeks in current year.
- · e – Country date format, to get time zone of server.
- · P – To get GMT value of server (+01:00)
3. getdate() – To get
current date and time information as array.
Example –
<?php
print_r(getdate());
?>
Output –
Array
(
[seconds] => 22
[minutes] => 39
[hours] => 12
[mday] => 31
[wday] => 2
[mon] => 1
[year] => 2017
[yday] => 30
[weekday] => Tuesday
[month] => January
[0] => 1485862762
)
4. checkdate() – To check
input date is existent or not.
Example –
<?php
echo checkdate(1,31,2017);
?>
Output –
1
No comments:
Post a Comment