Rabu, 18 September 2013

PHP Indonesia - Facebook: gan kalo mengitung selisih tanggal gimana gan? sy...

PHP Indonesia - Facebook
PHP Indonesia is a community for everyone that loves PHP. Our focus is in the PHP world but our topics encompass the entire LAMP stack. Topics include PHP coding, to memcached handling, db optimizations, server stack, web server tuning, code deploying, hosting options and much much more. Youtube Channel : http://www.youtube.com/user/OurPHPIndonesia Twitter : @php_indonesia NOTE: Rules for Wall posting: https://www.facebook.com/groups/35688476100/doc/10151597056316101/ Daftar Keanggotaan : http://www.facebook.com/groups/35688476100/doc/10150671770741101/ 
Refresh your vocabulary.

Learn a new word everyday by subscribing to Word of the Day. A great tool if you're studying for the GRE, GMAT or LSAT, or simply want to enhance your lexicon.
From our sponsors
gan kalo mengitung selisih tanggal gimana gan? sy...
Sep 18th 2013, 15:49, by Petrix Betoufa

Petrix Betoufa 3:49pm Sep 18
gan kalo mengitung selisih tanggal gimana gan?

sya sudah mencoba dengan cara

$date1 ="2014-12-20";
$date2 ="2014-12-21";
$pecah1 = explode("-", $date1);
$year1 = $pecah1[0];
$month1 = $pecah1[1];
$date1 = $pecah1[2];


$pecah2 = explode("-", $date2);
$year2 = $pecah2[0];
$month2 = $pecah2[1];
$date2 = $pecah2[2];

$jd1 = GregorianToJD($month1, $date1, $year1);
$jd2 = GregorianToJD($month2, $date2, $year2);
$jumlah = $jd1 - $jd2

tapi itu untuk format tanggalnya 2014-12-20
klo format tangal yg begini gimana gan 12/35/2013

Budi Sasongko 4:10pm Sep 18
$pecahz = explode("-", $date1);
$yearz = $pecah1[2];
$monthz = $pecah1[0];
$datez = $pecah1[1];

cmiiiiiiiiiiiw

Rohmi Irsyad 4:10pm Sep 18
kalau formatnya "12/35/2013" tinggal di rubah ke format "2014-12-20"

bisa dibuat function di PHP nya, misal seperti ini

function formatTimeNew($time){
$strTime=substr($time,6,4).'-'.substr($time,3,2).'-'.substr($time,0,2);

return $strTime;
}

Gembel Berkelas 4:11pm Sep 18
om pakek php versi berapa ???
kalo php 5 >= 5.3.0 gni aja

$first = new DateTime('2014-12-20');
$last = new DateTime('2014-12-21');

$interval = $first->diff( $last );
echo $interval->format('%R%a hari');

// Result : +1 hari

Budi Sasongko 4:13pm Sep 18
^^ kalo < 5.3.0 gmn ? :v

Rohmi Irsyad 4:14pm Sep 18
naah udah ada beberapa opsi tuh gan Petrix Betoufa, secara teknis banyak cara laah.. tinggal pake logika kita yg mana yg lbh mudah dan bs dterapin pake deh.. hehehe..
nama nya jg msh sama-sama belajar (y)

Gembel Berkelas 4:15pm Sep 18
:v

Petrix Betoufa 4:15pm Sep 18
ok gan q joba semua dulu, makasih semua

Gembel Berkelas 4:18pm Sep 18
kalo yg jd masalah cuma delimiter,,
Ane mah gni

$date = date('Y-m-d', strtotime('2014/12/20') );

Rohmi Irsyad 4:20pm Sep 18
hadeuuh die keluarin yg lebih simple.. wkawkawkakw :v mantap om Gembel Berkelas

Gembel Berkelas 4:22pm Sep 18
kata orang mah bnyak jalan menuju Roma,,,

ane mah boro2 ke Roma, ketemu bang Roma Irama aja belom pernah,,,

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions

Tidak ada komentar:

Posting Komentar