?
Solved

date conversion to full date

Posted on 2009-05-08
4
Medium Priority
?
267 Views
Last Modified: 2012-06-27
I have retrieved a date from my mysql database into a javascript variable and I am showing this javascript variable on a certificate. I am in UK so I want to present it day month year. So the date I return at the bottom for say 24th march 2009 is

24-03-2009.

However I want to display it as 24 March 2009.

Could anybody help me with that. This is purely for display purposes. Obviously I want this format for any date I return. Below is the mysql statement I ran from my php file to return the date.

Thanks.
$query = "SELECT passed, date_format(passdate,'%d-%m-%Y') as passdate FROM courses WHERE userref='$userref' and courseID='$courseID'";
$res2 = mysql_query($query) or fail("Failed getting passed from database");

Open in new window

0
Comment
Question by:RupertA
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
ycTIN earned 1000 total points
ID: 24335908
don't change the database date format

"SELECT passed, passdate FROM courses WHERE userref='$userref' and courseID='$courseID'";

<?php
echo date("d F Y", strtotime('24-03-2009'));
?>

Open in new window

0
 
LVL 7

Expert Comment

by:ycTIN
ID: 24335923
0
 

Author Comment

by:RupertA
ID: 24336961
not sure if I can use strtotime as  my variable is not necessariy 24-03-2009. It may be any date.

thanks.
0
 
LVL 17

Assisted Solution

by:nplib
nplib earned 1000 total points
ID: 24338581
strtotime() is very good at guessing the correct date

echo strtotime('24-03-2009');
echo strtotime('March 3, 2009');
echo strtotime('03/24/2009');

will all produce the same result.

best think is to try and limit the way the user can enter the date.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month14 days, 23 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question