Rss

About Me

My photo
SURAKARTA, JAWA TENGAH, Indonesia
Pernah bersekolah di SDN Begalon 2 Surakarta berlanjut ke SMP N 2 Grogol, Skh. Lalu ketika semester 3 pindah ke Banjarnegara, bersekolah si SMP N 2 Banjarnegara dikarenakan perintah orang tua. Dan saat semester ke 4 pindah lagi ke Solo dan bersekolah di SMP N 25 Surakarta. Sekitar tahun 2004/2005 lanjut ke SMK TP 2 Surakarta dan lulus pada tahun 2008. Mulai berkuliah di POLITEKNIK INDONUSA SURAKARTA pada tahun 2010. Minat saya hanya ingin bekerja dengan imajinasi saya, bukan dengan tenaga maupun berfikir hitung-hitungan yang ribet, hehe.. Saya ingin menjadi seorang desainer dan musisi.. :-D

Monday, May 21, 2012

How to Obtain Valid From Date Using PHP

Using the calendar, we can know the day of a date. For example, on May 10, 2012 is aThursday. How do I find out the name day of a date using PHP program?

It is very easy by using the date function in php. Consider the example program belowphp

<? php

$ date = "2012-05-10";

$ day = date ('l', strtotime ($ date);

echo "$ date $ date is a day of days";

?>

Description:

for example, on a day to be searched is dated May 10, 2012. I save this date into the variable $ date. The format must be 2012-05-10 (4 digit year, 2 digit month-on 2 digits)or can also use the Date Month Year (10 May 2012).

php date function is used to display the time. This function has the form

string date (string $ format [, int $ timestamp = time ()])

For the first parameter is mandatory, in the example program that I created above, useformat l (small L) which will display the name of a day in English (Sunday - Saturday). For the other formats can be viewed here. While for the second parameter, is optional, if notgiven, will use the current time on the server.

While the strtotime function to convert time into a Unix timestamp format.

The results of the program can be viewed here. Oiya's name was still in English, to switch to the Indonesian language, please try it yourself. Sometime I share again

0 comments:

Post a Comment

Coment here