Jump to content

Explode Ile Tarih Ve Saati Ayırmak Ve Fonksiyon Haline Getirmek


Recommended Posts

Merhaba arkadaşlar.
Veritabanından timestamp (CURRENT_TIMESTAMP) yapılı bir kolondan gelen tarih verisini tarih ve saat şeklinde yazdırmak amacıyla explode ile parçaladım. Ama her yerde kullanabilmem için bir fonksiyon yazdım.
Ancak fonksiyonu çalıştırma kısmını tam halledemedim eksikler var ama ne olduğunu bulamadım. Tarih ve Saat verisini ayrı ayrı nasıl yazdırabilirim?
Nasıl bir ekleme yapmalıyız? Yardımcı olur musunuz?

<?php
function TarihSaat($par){
		$zaman = $par;
		$zamanBol = explode(" ",$zaman);
		$tarih = $zamanBol[0];
		$saat2 = $zamanBol[1];
		$saat= substr($saat2, 0,5);
		echo $tarih;
		echo $saat;
	}

	//kayit_tarih sütunundaki tarih: 2017-08-26 01:30:37
	$k_tarih = $kayit_tarih["tarih"];
	TarihSaat($k_tarih);
?>

 

Link to comment
Share on other sites

  • Administrator

explode fonksiyonu stringleri parçalayabilir. $par ile geçtiğin değerin text formatında olduğundan emin misin?

ayrıca explode yerine tarih ve saati ayırmak için bu fonksiyonu da kullanabilirsin.

$date = date('Y-m-d', $par);
$time = date('H:i:s', $par);
Link to comment
Share on other sites

sk8er_boi, 5 saat önce yazdı:

explode fonksiyonu stringleri parçalayabilir. $par ile geçtiğin değerin text formatında olduğundan emin misin?

ayrıca explode yerine tarih ve saati ayırmak için bu fonksiyonu da kullanabilirsin.


$date = date('Y-m-d', $par);
$time = date('H:i:s', $par);

$par 'ın taşıdığı değer bu şekilde.  2017-08-26 01:30:37
Bu tarih ve saat verisi tek bir sütunda tutulduğundan ayırmak istiyorum saat ve tarih diye. Sizin dediğiniz şekilde fonksiyona nasıl uyarlayacağız?

Link to comment
Share on other sites

  • Administrator
<?php
function TarihSaat($par){
		
		
		$date = date('Y-m-d', $par);
		$time = date('H:i', $par);
		
		echo $tarih;
		echo $saat;
	}

	//kayit_tarih sütunundaki tarih: 2017-08-26 01:30:37
	$k_tarih = $kayit_tarih["tarih"];
	TarihSaat($k_tarih);
?>

 

Link to comment
Share on other sites

sk8er_boi, 32 dakika önce yazdı:

<?php
function TarihSaat($par){
		
		
		$date = date('Y-m-d', $par);
		$time = date('H:i', $par);
		
		echo $tarih;
		echo $saat;
	}

	//kayit_tarih sütunundaki tarih: 2017-08-26 01:30:37
	$k_tarih = $kayit_tarih["tarih"];
	TarihSaat($k_tarih);
?>

 

Teşekkür ederim. Peki fonksiyon bu şekilde olacak ama ben sadece fonksiyonun içerisindeki tarih verisine erişmek istersem ya da saat. Bu durumda nasıl bir senaryo olmalı? Bu verilere nasıl ulaşabiliriz?

Edited by Abdullah 37
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Similar Content

    • By artae
      Blumentals Rapid PHP 2022 v17.2.0.242 Multilingual | 116.7 Mb

      Rapid PHP editor is a faster and more powerful PHP code editor for Windows combining features of a fully-packed PHP IDE with the speed of the Notepad.

      Rapid PHP is the most complete all-in-one software for coding PHP, HTML, CSS, javascript and other web development languages with tools for debugging, validating, reusing, navigating and formatting your code.
      The fastest PHP editor / IDE
      Loads much faster than any other PHP editor or PHP IDE with similar features
      Powerful syntax highlighting
      Supports HTML, CSS, javascript, PHP, Smarty, XML, SQL, Apache and more
      Code intelligence
      Tons of intelligent code completion, navigation and suggestion features for PHP, HTML, CSS, javascript, Smarty
      Powerful editor
      Unicode support, bracket-matching, code folding, auto-complete, auto-replace, multi-highlight and more
      HTML5 and CSS3 ready
      Coding features are up-to-date with modern standards
      Powerful CSS features
      Inspector, compatibility watch, prefixizer, code assistants, browser preview and much more
      Advanced search and replace
      Goto anything, quick search, detailed search, file search, regular expressions, detailed results and more
      Smarty & framework support
      Powerful support for Smarty PHP template ee and popular PHP frameworks
      Debugger & validators
      xDebug PHP debugger, real PHP checker, spelling checker, W3 HTML and CSS validator, JSLint javascript checker
      Direct FTP/SFTP/FTPS
      Edit directly on your web server or publish local development copy updates with a single click
      Efficient code re-use
      Code snippet library and code templates with assignable shortcuts
      Loads of tools
      Code beautifier, dynamic ToDo, color picker, XRay etc.
      Windows 7, 8, 10, 11
      -
      DOWNLOAD
      (Buy premium account for maximum speed and resuming ability)


      https://nitroflare.com/view/E09DDFFDA3F427E/5qyio.Blumentals.Rapid.PHP.2022.v17.2.0.242.Multilingual.rar



      https://rapidgator.net/file/256f2a2509d9805b93e30092b928665b/5qyio.Blumentals.Rapid.PHP.2022.v17.2.0.242.Multilingual.rar


    • By artae
      Blumentals Rapid PHP 2022 v17.0.0.240. Multilingual | 112.3 Mb
      Rapid PHP editor is a faster and more powerful PHP code editor for Windows combining features of a fully-packed PHP IDE with the speed of the Notepad. Rapid PHP is the most complete all-in-one software for coding PHP, HTML, CSS, javascript and other web development languages with tools for debugging, validating, reusing, navigating and formatting your code.

      The fastest PHP editor / IDE
      Loads much faster than any other PHP editor or PHP IDE with similar features
      Powerful syntax highlighting
      Supports HTML, CSS, javascript, PHP, Smarty, XML, SQL, Apache and more
      Code intelligence
      Tons of intelligent code completion, navigation and suggestion features for PHP, HTML, CSS, javascript, Smarty
      Powerful editor
      Unicode support, bracket-matching, code folding, auto-complete, auto-replace, multi-highlight and more
      HTML5 and CSS3 ready
      Coding features are up-to-date with modern standards
      Powerful CSS features
      Inspector, compatibility watch, prefixizer, code assistants, browser preview and much more
      Advanced search and replace
      Goto anything, quick search, detailed search, file search, regular expressions, detailed results and more
      Smarty & framework support
      Powerful support for Smarty PHP template engine and popular PHP frameworks
      Debugger & validators
      xDebug PHP debugger, realtime PHP checker, spelling checker, W3 HTML and CSS validator, JSLint javascript checker
      Direct FTP/SFTP/FTPS
      Edit directly on your web server or publish local development copy updates with a single click
      Efficient code re-use
      Code snippet library and code templates with assignable shortcuts
      Loads of tools
      Code beautifier, dynamic ToDo, color picker, XRay etc.
      Operating System:Windows 7, 8, 10
      Home Page -https://www.rapidphpeditor.com/
      DOWNLOAD
      (Buy premium account for maximum speed and resuming ability)


      https://nitroflare.com/view/B8818BDF4105D08/kz6qv.Blumentals.Rapid.PHP.2022.v17.0.0.240.Multilingual.rar



      https://rapidgator.net/file/3d9484b81940155cfd8646bc0f8a1a08/kz6qv.Blumentals.Rapid.PHP.2022.v17.0.0.240.Multilingual.rar


    • By prototype
      Merhaba arkadaşlar index.php sayfasında Session oluşturup, sayfa2.php'de listelettiriyorum. Ama ben session'ı oluşturduktan sonra otomatik olarak sayfa2.php'ye yönlendirme yapmasını istiyorum, nasıl yapabileceğim konusunda bana yardımcı olabilirseniz çok sevinirim. Teşekkürler.

      index.php
      <?php session_start(); ?> <!doctype html> <html> <head> <title>Session Oluştur</title> </head> <body> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> Ürün Adı :<input type="text" name="urunadi"> Alış Fiyati :<input type="text" name="alisfiyati"> Müşteri Adı :<input type="text" name="musteriadi"> <input type="submit" name="submit" value="Submit"> </form> <br> <a href="sayfa2.php">2.Sayfaya Git </a><br> <a href="sayfa3.php">3.Sayfaya Git </a> <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $_SESSION['uadi']=$_POST['urunadi']; $_SESSION['afiyati']=$_POST['alisfiyati']; $_SESSION['madi']=$_POST['musteriadi']; } ?> </body> </html>
      sayfa2.php
       
      <?php session_start(); ?> <!doctype html> <html> <head> <title>Session Listeleme</title> </head> <body> <?php if(isset($_SESSION["uadi"])&&isset($_SESSION["afiyati"])&&isset($_SESSION["madi"])) { ?> Ürün Adı : <?php echo $_SESSION['uadi']; ?><br> Alış Fiyatı : <?php echo $_SESSION['afiyati']; ?><br> Müşteri Adı : <?php echo $_SESSION['madi']; }?><br> <a href="index.php">1.Sayfaya Git </a> </body> </html>  
    • By Abdullah 37
      Merhaba arkadaşlar.
      Php ile mysql işlemleri yaparken güvenlik kısmında tam olarak ne yapılması gerektiğini bilmiyorum. Bu konuda yardımlarınıza ihtiyacım var.
      - Üye kayıt ve giriş kısmını kodlarken gelen verileri hangi güvenlik fonksiyonlarından geçirmeliyim?
      - Konu ekleme ve düzenleme, yorum ekleme ve düzenleme kısımlarını hangi güvenlik fonksiyonlarından geçirmeliyim?
    • By maxrekor
      ArkadaşLar Merhaba Win 7 X64 Saat 1 saat geriden Takip Ediyor Bios dan AyarLıyorum PC yi açıLınca Eskisi gibi oLuyor, Windows dan yapıyorum bi kaç gün sonra Eskiye dönüyor yani 1 saat geriye. SaatLeri devLet geri aLmayınca başLadı Sorun
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...