Jump to content


Photo

Converting mktime to a normal date


  • Please log in to reply
4 replies to this topic

#1 cturner

cturner
  • Members
  • PipPipPip
  • Advanced Member
  • 148 posts
  • LocationMy computer

Posted 24 October 2006 - 10:58 AM

Can someone please tell me how I can convert a mktime date (mktime(0,0,0,$month -1,$d,$year)) to something like 21 October 2006? Thanks in advance.

#2 heckenschutze

heckenschutze
  • Members
  • PipPipPip
  • Advanced Member
  • 257 posts
  • LocationAustralia

Posted 24 October 2006 - 11:01 AM

Use date()

eg:
<?php
echo date("d F Y", mktime(0, 0, 0, $month -1, $d, $year));
?>


#3 cturner

cturner
  • Members
  • PipPipPip
  • Advanced Member
  • 148 posts
  • LocationMy computer

Posted 24 October 2006 - 11:15 AM

Thanks for your reply heckenschutze but it is displaying 0 as the 1st day of a month. I am clicking on a date in a calendar to come to the code that is below.

require "config.php";

// get the entry date
$entry_date = $_GET['entry_date'];

// select the diary entry for the entry_date
$query = "SELECT * FROM `diary_contents` WHERE `date` = '$entry_date'";

// display the diary entries for the entry date
echo date("w F Y", $entry_date);

// more code to come


#4 heckenschutze

heckenschutze
  • Members
  • PipPipPip
  • Advanced Member
  • 257 posts
  • LocationAustralia

Posted 24 October 2006 - 11:17 AM

use 'j' instead of 'd'...

echo date("j F Y", $entry_date);



#5 cturner

cturner
  • Members
  • PipPipPip
  • Advanced Member
  • 148 posts
  • LocationMy computer

Posted 24 October 2006 - 11:19 AM

Problem is now solved thanks to heckenschutze.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users