PHP date function .

Veröffentlicht am: 27 Februar 2017
auf dem Kanal: Student Projects Live
326
1

Welcome to PHP programming,
In PHP, date() function is used to format a time or a date.

The PHP date() function

The date() function formats a timestamp to a more readable date and time.

Syntax:
date(format,timestamp)

Format - required, specifies the format of the timestamp.

Timestamp - optional, specifies a timestamp.
Default is the current date and time as a timestamp.

What is a Timestamp?

A timestamp is the number of seconds since January 1, 1970 at 00:00:00 GMT. This is also known
as the Unix Timestamp.

Format the date

The first parameter in the date() function specifies how to format the date time. It uses letters
to represent date and time formats. Here are some of the letters that can be used.

1) d - The day of the month(01-31)
2) m - The current month, as a number(01-12)
3) y - The current year in 2 digits

4) D - The day of the week
5) M - The current month, with a first 3 letters of the month
6) Y - The current year in four digits

7) h - The current time in hours
8) i - The current time in minutes
9) s - The current time in seconds
10) a - specifies am and pm

Let us write a PHP code using date function

Save it in our server i.e. xampp/htdocs

Run the code using the url http://localhost/date1.php


Adding a Timestamp

The second parameter in the date() function specifies a timestamp. This parameter is optional. If
you do not supply a timestamp, the current time will be used.

Let us use the mktime9) function to create a timestamp for tomorrow.

The mktime() function returns the Unix timestamp for a specified date.

Syntax:

mktime(hour,minute,second, month, day, year, is_dst)

Let us write a simple PHP code using mktime() function to create a timestamp for tomorrow.

Save it in our server i.e., xampp/htdocs

run the code using the url http://localhost/date2.php

This is how date functions works in PHP script.

Thank You...........

Author - Krithika


For source code kindly refer www.studentprojects.live

Do you have Any queries? Contact us in Whatsapp :- +91-9972853368

#studentprojects #phpcode


Auf dieser Seite können Sie das Online-Video PHP date function . mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Student Projects Live 27 Februar 2017 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 326 Mal angesehen und es wurde von 1 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!