sponsor

Showing posts with label function. Show all posts
Showing posts with label function. Show all posts

Monday, January 12, 2009

how to get number of days in the month with php

if you want to know number of days in the month with php, you can call function cal_days_in_month()
this function returns the number of days in a given month, based on the calendar, month, and year that you specify

the format of this function is
Cal_days_in_month (calendar, Month, year)
This function have three parameters,
  • calendar, you can fill this parameter with CAL_GREGORIAN
  • month, you can fill this parameter with month (1 - 12)
  • year, you can fiil this parameter with 4 digits of year (2008)
example :
$days = cal_days_in_month(CAL_GREGORIAN, 1, 2009) ;
echo "In January 2009 there were $days days";
?>

that example will display
In january 2009 there were 31 days

Monday, January 7, 2008

Getting Started with jQuery

This guide is an introduction to the jQuery library. Basic knowledge of JavaScript and the document object model (DOM) is required. It starts from ground up and tries to explain details where necessary. It covers a simple hello world example, selector and event basics, AJAX, FX and usage and authoring of plugins.

This guide contains no "click me" examples. The intention of providing only "copy me" code is to invite you to try it for yourself. Copy an example, see what it does, and modify it.

Setup

To start, we need a copy of the jQuery library, which we can get from the main download page. The jQuery Starterkit provides some markup and CSS to work with. After downloading and extracting its content we put jquery.js into the same directory and open starterkit.html and custom.js with our favorite editor and starterkit.html with a browser.

Now we have everything to start with the notorious "Hello world" example.

Hello jQuery

We start with an empty html page:

<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
// we will add our javascript code here
</script>
</head>
<body>
<--- we will add our HTML content here -->
<body>
<html>

This page just loads the jquery.js library (make sure the URL points to where you stored your copy of jquery! This example assumes that you store it in the same directory as this example file). Two comments indicate where we will expand this template with code.

As almost everything we do when using jQuery reads or manipulates the document object model (DOM), we need to make sure that we start adding events etc. as soon as the DOM is ready.

To do this, we register a ready event for the document.

$(document).ready(function() {
// do stuff when DOM is ready
});

Putting an alert into that function does not make much sense, as an alert does not require the DOM to be loaded. So lets try something a little more sophisticated: Show an alert when clicking the link.

$(document).ready(function() {
$("a").click(function() {
alert("Hello world!");
});
});

This should show the alert as soon as you click on the link.

Lets have a look at what we are doing: $("a") is a jQuery selector, in this case, it selects all a elements. $ itself is an alias for the jQuery "class", therefore $() constructs a new jQuery object. The click() function we call next is a method of the jQuery object. It binds a click event to all selected elements (in this case, a single anchor element) and executes the provided function when the event occurs.

This is similar to the following code:

Link

The difference is quite obvious: We don't need to write an onclick for every single element. We have a clean separation of structure (HTML) and behavior (JS), just as we separate structure and presentation by using CSS.

With this in mind, we explore selectors and events a little further.

Monday, November 26, 2007

Moontox Bro, ada hubungan apa ya sama rontokbro?

By: Hacker/Cracker Indonesia ]
---- Paraysutki #VM Community ----
[ SEND TO MALAYSIA/AUSTRALIA



Hentikanlah kebobrokan kalian --
Apa kalian tau rasanya menjadi manusia yang sia-sia?
Apa kalian tau rasanya setiap saat dihina dan tidak mampu merasakan kesenangan kalian?
Apa kalian tau betapa sakitnya kami (TKI) yang disiksa dan di perlakukan seperti binatang oleh majikan kalian? ditendang,dipukuli,dicaci maki,dihina,tidak digajih,dan pulang dengan anggota tubuh yg cacat? itulah yang kami dapatkan sehari-hari selama bekerja di sana
Aku yakin selama hidup kalian tidak pernah sedikitpun merasakan rasa sakit itu?

Wahai kalian yang ada di bumi ini
Kalian yang telah memojokanku dan Kalian yang telah merusak semua kesenanganku
Kalian hanya melihatku sebagai anak yang menyedihkan yang harus kalian singkirkan
kalian hanya memberiku satu-satunya jalan untuk membalas keputusan yang telah kalian buat

...Terima kasih...
kini kalian akan melihat darah di kedua tanganmu yang tak akan pernah bisa di bersihkan
dan kini aku akan hadir membangkitkan generasi yang lemah dan tak berdaya untuk melawan
!!! Bangkitlah Indonesia Raya, Bangsa dan Tanah Airku !!!


Itulah sebuah pesan yang berasal dari virus baru "Moontox Bro". Info lebih lengkapnya baca di sini. Melihat nama virus ini, jadi inget sama virus yang beberapa waktu lalu sempat ngetrend karena merepotkan semua orang, rontokbro. Apa ya hubungan mereka berdua?

Gak penting apa hubungan mereka berdua. Tapi yang jelas, kalo aku ngeliat dari vaksin.com, virus ini lebih berbahaya dibandingkan rontokbro. Kenapa aku bilang demikian? Karena di dalam keterangan vaksin.com, virus ini akan memformat semua partisi harddisk kecuali C:. bahaya bukan?

Kalo dilihat dari pesan yang ada di atas, virus ini berisi kecaman kepada Australia dan Malaysia yang telah berbuat semena-mena. Tapi sungguh aneh, kalo memang tujuannya untuk itu, kenapa virus ini disebarkan di Indonesia? Kenapa tidak disebarkan "hanya" di ke2 negara itu saja?

Btw, udah ada yang kena virus ini belum ya? Mudah2an seh belum ada. Oke, seperti kata pepatah lebih baik mencegah daripada mengobati. Sebelum virus menyerang, ada baiknya kita mencegahnya terlebih dahulu. Apa langkah-langkah yang harus dilakukan?
1. Matikan fasilitas autorun karena virus ini akan menyebar via USB.
2. Cegah file virus agar tidak bisa dieksekusi. Caranya : masuk ke Run -> gpedit.msc.
Akan muncul window Group Policy.






Kemudian masuk ke menu User Configuration -> Administrative Templates -> System. Kemudian di sebelah kanan ada list. Klik 2 kali pada tulisan. "Don't run Specified Windows application". Pilih "Enabled" dan klik tombol "Show". Klik tombol Add dan akan muncul sebuah window baru. Masukkan string Baca_Gue_Goblok.bat. Klik tombol OK. Lakukan hal yang sama untuk string Send To Hell.vbs dan juga Baca_GUe_Goblok.cmd.

Sesudah langkah-langkah di atas diikuti, selanjutnya tinggal berdoa aja. Mudah2an virus tidak akan menjangkiti komputer Anda. amin........

Friday, October 26, 2007

Fungsi PHP untuk menghitung umur

Umur seseorang dihitung berdasarkan perbedaan tanggal lahirnya dengan tanggal sekarang. Kali ini saya akan memberikan fungsi PHP untuk menghitung umur.


//sebuah function dengan nama hitUmur dan sebuah parameter
function hitUmur($tgllahir) {
$tgl = explode("-", $tgllahir);
// memecah $tgllahir yang tadinya YYYY-MM-DD menjadi array
// $tgl[0] = tahun (YYYY)
// $tgl[a] = bulan (MM)
// $tgl[2] = hari (DD)

$umur = date("Y") - $tgl[0]; //ini untuk ngitung umurnya

if(($tgl[1] > date("m")) || ($tgl[1] == date("m") && date("d") < $tgl[2])) //ngecek apakah tgl lahir dan bulannya belum lewat?
{

$umur -= 1;
}
return $umur;
}

//cara mengakses fungsi
$tgllahirku = "1980-10-12";
echo hitUmur($tgllahirku);
?>

Monday, May 21, 2007

Date Function on PHP

to display the time and date in PHP, we can use date function. This function have several parameter. example

<?
date('d-m-y h:i:s')
?>
this syntax will return 21-05-2007 15:25:32.
For other parameters, please try to change the example above.
format character Description Example returned values
a Lowercase Ante meridiem and Post meridiem am or pm
A Uppercase Ante meridiem and Post meridiem AM or PM
B Swatch Internet time 000 through 999
d Day of the month, 2 digits with leading zeros 01 to 31
D A textual representation of a day, three letters Mon through Sun
F A full textual representation of a month, such as January or March January through December
g 12-hour format of an hour without leading zeros 1 through 12
G 24-hour format of an hour without leading zeros 0 through 23
h 12-hour format of an hour with leading zeros 01 through 12
H 24-hour format of an hour with leading zeros 00 through 23
i Minutes with leading zeros 00 to 59
I (capital i) Whether or not the date is in daylights savings time 1 if Daylight Savings Time, 0 otherwise.
j Day of the month without leading zeros 1 to 31
l (lowercase 'L') A full textual representation of the day of the week Sunday through Saturday
L Whether it's a leap year 1 if it is a leap year, 0 otherwise.
m Numeric representation of a month, with leading zeros 01 through 12
M A short textual representation of a month, three letters Jan through Dec
n Numeric representation of a month, without leading zeros 1 through 12
O Difference to Greenwich time (GMT) in hours Example: +0200
r RFC 822 formatted date Example: Thu, 21 Dec 2000 16:01:07 +0200
s Seconds, with leading zeros 00 through 59
S English ordinal suffix for the day of the month, 2 characters st, nd, rd or th. Works well with j
t Number of days in the given month 28 through 31
T Timezone setting of this machine Examples: EST, MDT ...
U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) See also time()
w Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday)
W ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0) Example: 42 (the 42nd week in the year)
Y A full numeric representation of a year, 4 digits Examples: 1999 or 2003
y A two digit representation of a year Examples: 99 or 03
z The day of the year 0 through 366
Z Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. -43200 through 43200