function turkce_tarih($tarih = ""){
if ($tarih=="")
$tarih = date("Y-m-d H:i:s");
$tarihDizi["gunler"] = array("Pazar","Pazartesi","Salı","Çarşamba","Perşembe","Cuma","Cumartesi");
$tarihDizi["aylar"] = array ("01" => "Ocak", "02" => "Şubat", "03" => "Mart", "04" => "Nisan", "05" => "Mayıs", "06" => "Haziran",
"07" => "Temmuz", "08" => "Ağustos", "09" => "Eylül", "10" => "Ekim", "11" => "Kasım", "12" => "Aralık");
$zamanExp = explode (" ",$tarih);
$tarihExp = explode ("-",$zamanExp[0]);
$haftaninGunu=strftime("%w",strtotime($tarih));
$tarihFormat["ay"] = $tarihDizi["aylar"][$tarihExp[1]];
$tarihFormat["haftanin_gunu"] = $tarihDizi["gunler"][$haftaninGunu];
$tarihFormat["saat"] = $zamanExp[1];
$tarihFormat["format1"] = $tarihExp[2]." ".$tarihFormat["ay"]." ".$tarihExp[0];
$tarihFormat["format2"] = $tarihFormat["format1"]." ".$tarihFormat["saat"];
$tarihFormat["format3"] = $tarihExp[2]." ".$tarihFormat["ay"]." ".$tarihExp[0];
$tarihFormat["format4"] = $tarihFormat["format3"]." ".$tarihFormat["haftanin_gunu"];
return $tarihFormat;
}
################################################################
# human time fn
################################################################
function tarih_yazilma($tarih) {
$fark_tarih = time() - $tarih;
$kontrol_tarih_saniye = $fark_tarih;
$kontrol_tarih_dakika = round( $fark_tarih / 60 );
$kontrol_tarih_saat = round( $fark_tarih / 3600 );
if($kontrol_tarih_saniye < 60 ) {
echo $kontrol_tarih_saniye .' saniye önce'; }
elseif ($kontrol_tarih_dakika < 60 ) {
echo $kontrol_tarih_dakika .' dakika önce'; }
elseif ($kontrol_tarih_saat < 24 ) {
echo $kontrol_tarih_saat .' saat önce';
} else {
$formatliTarih = turkce_tarih(get_post_time('Y-m-d'));
echo $formatliTarih["format4"];
}
}çok saçma saat ve tarih ekliyor benim istediğim tarih ve yanında saatin yazması bunu nasıl yapabilirim yardımcı olacak arkadaşlarıma şimdiden tşkler.
PHP Yardım Bi konuda bir yerde takıldım
15
●977
- 07-09-2013, 23:55:40arkadaşlar merhaba; function.php dusyamda saat ve tarih formatı bu şekil
- 08-09-2013, 00:49:42hocam php bilgim yok wordpress bu function.php de tarih saat kodu bu kodlarla yapılmışbiomooj adlı üyeden alıntı: mesajı görüntüle
- 08-09-2013, 01:33:22Üyeliği durduruldu
$kontrol_tarih_dakika = round( $fark_tarih / 00 );
satırını
$kontrol_tarih_dakika = round( $fark_tarih / 60 );
olarak değiştirirseniz sıkıntı kalkacaktır. Yazım hatası yapılmış sanırım. - 08-09-2013, 03:48:28hocam ben yalnış kod eklemişim kodu şimdi güncelledim kod çalışıyor aslına ama 46444 saniye önce eklenmiş diyor yani direk saati yazdıramammı veya ne biliyim 20 sn önce eklenmiş gibiistanbullili adlı üyeden alıntı: mesajı görüntüle
- 08-09-2013, 13:53:11Üyeliği durdurulduekrem çolak adlı üyeden alıntı: mesajı görüntüle
<?php function turkce_tarih($tarih = ""){ if ($tarih=="") $tarih = date("Y-m-d H:i:s"); $tarihDizi["gunler"] = array("Pazar","Pazartesi","Salı","Çarşamba","Perşembe","Cuma","Cumartesi"); $tarihDizi["aylar"] = array ("01" => "Ocak", "02" => "Şubat", "03" => "Mart", "04" => "Nisan", "05" => "Mayıs", "06" => "Haziran", "07" => "Temmuz", "08" => "Ağustos", "09" => "Eylül", "10" => "Ekim", "11" => "Kasım", "12" => "Aralık"); $zamanExp = explode (" ",$tarih); $tarihExp = explode ("-",$zamanExp[0]); $haftaninGunu=strftime("%w",strtotime($tarih)); $tarihFormat["ay"] = $tarihDizi["aylar"][$tarihExp[1]]; $tarihFormat["haftanin_gunu"] = $tarihDizi["gunler"][$haftaninGunu]; $tarihFormat["saat"] = $zamanExp[1]; $tarihFormat["format1"] = $tarihExp[2]." ".$tarihFormat["ay"]." ".$tarihExp[0]; $tarihFormat["format2"] = $tarihFormat["format1"]." ".$tarihFormat["saat"]; $tarihFormat["format3"] = $tarihExp[2]." ".$tarihFormat["ay"]." ".$tarihExp[0]; $tarihFormat["format4"] = $tarihFormat["format3"]." ".$tarihFormat["haftanin_gunu"]; $tarihFormat["format5"] = $tarihFormat["format3"]." ".$tarihFormat["haftanin_gunu"]." ".$tarihFormat["saat"]; return $tarihFormat; } ################################################################ # human time fn ################################################################ function tarih_yazilma($tarih) { $formatliTarih = turkce_tarih($tarih); echo $formatliTarih["format5"]; } tarih_yazilma(get_post_time('Y-m-d H:i:s')); ?>Şu şekilde bir deneyin. Şu anda malesef elimde test edebileceğim wordpress sitesi yok. Bu kodun çıktısı
06 Temmuz 2013 Cumartesi 16:24:35 - 08-09-2013, 22:11:24istanbullili adlı üyeden alıntı: mesajı görüntüle
hocam eklledim fakat tarih ve saat en üstte gözüktü yalnız yazdığınız kodda şuraları sildim <?php ?>
hata veriyor yoksa - 08-09-2013, 22:16:58Üyeliği durdurulduEvet, çünkü dosyanın komple içeriğini yazmış arkadaş. Sen ilk mesajında sadece bu kodun olduğu kısmı kopyalamışsın. .php uzantılı dosyanın tam içeriğini buraya yazarsan entegrede nasıl hata yaptığını söyler doğrusunu veririm.ekrem çolak adlı üyeden alıntı: mesajı görüntüle
Bir PHP kodu <?php ile başlar, ?> ile biter. Kopyala bakalım buraya dosyanı, nerede hata yaptın görelim.
- 08-09-2013, 22:20:11Abstract adlı üyeden alıntı: mesajı görüntüle
<?php ################################################################ # meta box ekleme ################################################################ add_action( 'add_meta_boxes', 'cd_add_quote_meta' ); function cd_add_quote_meta() { add_meta_box( 'quote-meta', 'Haber resim', 'cd_quote_meta_cb', 'post', 'normal', 'high' ); } if ( !function_exists( 'optionsframework_init' ) ) { define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/inc/' ); require_once dirname( __FILE__ ) . '/inc/options-framework.php'; } function cd_quote_meta_cb( $post ) { $resim = get_post_meta( $post->ID, 'resim', true ); wp_nonce_field( 'save_quote_meta', 'kutucuk' ); ?> <p> <label for="resim">Haber resmi</label> <input type="text"name="resim" style="width:500px;" value="<?php echo $resim; ?>" /> Öne çıkarılmış görseli de kullanabilirsiniz. </p> <?php } add_action( 'save_post', 'cd_quote_meta_save' ); function cd_quote_meta_save( $id ) { if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; if( !isset( $_POST['kutucuk'] ) || !wp_verify_nonce( $_POST['kutucuk'], 'save_quote_meta' ) ) return; if( !current_user_can( 'edit_post' ) ) return; $allowed = array( 'p' => array() ); if( isset( $_POST['resim'] ) ) update_post_meta( $id, 'resim', esc_attr( strip_tags( $_POST['resim'] ) ) ); } ################################################################ # tarihi turkcelestiren fn ################################################################ function turkce_tarih($tarih = ""){ if ($tarih=="") $tarih = date("Y-m-d H:i:s"); $tarihDizi["gunler"] = array("Pazar","Pazartesi","Salı","Çarşamba","Perşembe","Cuma","Cumartesi"); $tarihDizi["aylar"] = array ("01" => "Ocak", "02" => "Şubat", "03" => "Mart", "04" => "Nisan", "05" => "Mayıs", "06" => "Haziran", "07" => "Temmuz", "08" => "Ağustos", "09" => "Eylül", "10" => "Ekim", "11" => "Kasım", "12" => "Aralık"); $zamanExp = explode (" ",$tarih); $tarihExp = explode ("-",$zamanExp[0]); $haftaninGunu=strftime("%w",strtotime($tarih)); $tarihFormat["ay"] = $tarihDizi["aylar"][$tarihExp[1]]; $tarihFormat["haftanin_gunu"] = $tarihDizi["gunler"][$haftaninGunu]; $tarihFormat["saat"] = $zamanExp[1]; $tarihFormat["format1"] = $tarihExp[2]." ".$tarihFormat["ay"]." ".$tarihExp[0]; $tarihFormat["format2"] = $tarihFormat["format1"]." ".$tarihFormat["saat"]; $tarihFormat["format3"] = $tarihExp[2]." ".$tarihFormat["ay"]." ".$tarihExp[0]; $tarihFormat["format4"] = $tarihFormat["format3"]." ".$tarihFormat["haftanin_gunu"]; return $tarihFormat; } ################################################################ # human time fn ################################################################ function tarih_yazilma($tarih) { $fark_tarih = time() - $tarih; $kontrol_tarih_saniye = $fark_tarih; $kontrol_tarih_dakika = round( $fark_tarih / 60 ); $kontrol_tarih_saat = round( $fark_tarih / 3600 ); if($kontrol_tarih_saniye < 60 ) { echo $kontrol_tarih_saniye .' saniye önce'; } elseif ($kontrol_tarih_dakika < 60 ) { echo $kontrol_tarih_dakika .' dakika önce'; } elseif ($kontrol_tarih_saat < 24 ) { echo $kontrol_tarih_saat .' saat önce'; } else { $formatliTarih = turkce_tarih(get_post_time('Y-m-d')); echo $formatliTarih["format4"]; } } ################################################################ # sayfalama ################################################################ function yazisayfalama($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 4, $always_show = false) { global $request, $posts_per_page, $wpdb, $paged; if(empty($prelabel)) { $prelabel = 'Önceki'; } if(empty($nxtlabel)) { $nxtlabel = 'Sonraki'; } $half_pages_to_show = round($pages_to_show/2); if (!is_single()) { if(!is_category()) { preg_match('#FROM\s(.*)\sORDER BY#siU', $request, $matches); } else { preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches); } $fromwhere = $matches[1]; $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere"); $max_page = ceil($numposts /$posts_per_page); if(empty($paged)) { $paged = 1; } if($max_page > 1 || $always_show) { echo "$after $before"; previous_posts_link($prelabel); if ($paged >= ($pages_to_show)) { echo '<a href="'.get_pagenum_link().'">1</a>'; } for($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) { if ($i >= 1 && $i <= $max_page) { if($i == $paged) { echo '<a class="aktif" title="Sayfa '.$i.'" >'.$i.'</a>'; } else { echo ' <a class="sayfa" href="'.get_pagenum_link($i).'" title="Sayfa '.$i.'">'.$i.'</a> '; } } } if (($paged+$half_pages_to_show) < ($max_page)) { echo '<a class="sayfa" href="'.get_pagenum_link($max_page).'">'.$max_page.'</a>'; } next_posts_link($nxtlabel, $max_page); } } } ################################################################ # sidebar dinamik ################################################################ if ( function_exists('register_sidebar') ) register_sidebar(array('name'=>'Yan Menu', 'before_widget' => '<div class="bilesen">', 'after_widget' => '</div></div>', 'before_title' => '<h2 class="baslik">', 'after_title' => '</h2><div class="bilesen-ic">', )); ################################################################ # anasayfa haber blokları ################################################################ function anasayfaHaberBlok($kat_id = "",$renk) { ?> <div class="haber-blok <?php echo $renk; ?>-haber-blok"> <div class="baslik"> <?php if($kat_id) { ?> <h2><a href="<?php echo get_category_link($kat_id); ?>"><?php echo get_cat_name($kat_id); ?></a></h2> <span class="icon-angle-right" data-href="<?php echo get_category_link($kat_id); ?>"></span> <?php } else { ?> <h2><a>Son Haberler</a></h2> <?php } ?> </div> <div class="ic t"> <?php query_posts('cat='.$kat_id.'&showposts=5'); while ( have_posts() ) : the_post(); $haber_say++; ?> <?php if($haber_say == 1) { ?> <div class="haber-buyuk"> <div class="sol"> <a href="<?php the_permalink(); ?>"><?php resim(280,170); ?></a> </div> <div class="sag"> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <span class="ozet"> <?php the_excerpt(); ?> </span> <div class="detay"> <time class="tarih"><?php tarih_yazilma(get_the_time("U")); ?></time> </div> </div> </div><!--/haber-buyuk--> <div class="tem"></div> <?php } else { ?> <div class="haber-kucuk"> <a class="resim" href="<?php the_permalink(); ?>"><?php resim(175,100); ?></a> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> </div> <?php } ?> <?php endwhile;wp_reset_query(); ?> </div> </div><!--/haber-blok--> <?php } ################################################################ # üst menu altı 5li haber ################################################################ function besli_haber() { $besli_kat = of_get_option(besli_kat); ?> <div class="besli" id="besli"> <ul class="t"> <?php query_posts('cat='.$besli_kat.'&showposts=5'); while ( have_posts() ) : the_post(); ?> <li> <span class="icon-link" data-link="<?php the_permalink(); ?>"></span> <a href="<?php the_permalink(); ?>"> <?php resim(175,100); ?> </a> <a class="baslik" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> </li> <?php endwhile;wp_reset_query(); ?> </ul> </div><!--/besli--> <?php } ################################################################ # kategori ? yazının kategori ################################################################ function kategori_esit_mi_yazininkine($yazi_id) { $foto_kat = of_get_option(foto_kat); $video_kat = of_get_option(video_kat); foreach((get_the_category($yazi_id)) as $kat) { if($kat->cat_ID == $foto_kat) { echo '<span class="icon-camera"></span>'; } elseif($kat->cat_ID == $video_kat) { echo '<span class="icon-facetime-video"></span>'; } } } ################################################################ # ek include (silme) ################################################################ include("lib/sablon/ek.php"); ################################################################ # v2 versiyon kodları aşağıdadır. # güncelenme tarihi : 28.04.2013 ################################################################ ################################################################ # register nav menu ################################################################ register_nav_menu( 'en_ust_menu', 'En üst menü'); ################################################################ # resim adres ################################################################ function resim_adres() { global $post; if (get_post_meta($post->ID, 'resim', true) != '') { $resim = get_post_meta($post->ID, 'resim', true); ?> <?php echo $resim ?> <?php } elseif(has_post_thumbnail()) { ?> <?php $hpt = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail_size' ); echo $hpt[0]; ?> <?php } else { ?> <?php echo bloginfo('template_url'); ?>/resimyok.png <?php } }
buyurun hocam dosyadaki bütün kodlar