473,801 Members | 2,316 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Displaying DATE or DATETIME in PHP

Hello,

I'm still pretty new to PHP and MySQL, and have a PHP scripting
question.

If I'm querying DATE info from a MySQL database, and displaying it
with PHP echo statements... is there a PHP script I can use to convert
the DATE data to standard calendar format?

Example:

2007-10-12 displayed as October 12, 2007

Thank you,

Colleen Robledo

Oct 16 '07 #1
2 2091
On Tue, 16 Oct 2007 09:42:28 +0200, Colleen Robledo, MLIS
<co************ @gmail.comwrote :
Hello,

I'm still pretty new to PHP and MySQL, and have a PHP scripting
question.

If I'm querying DATE info from a MySQL database, and displaying it
with PHP echo statements... is there a PHP script I can use to convert
the DATE data to standard calendar format?

Example:

2007-10-12 displayed as October 12, 2007
You are better of using the DATE_FORMAT(dat e_field, '%M %e, %Y') function
in MySQL, as it knows for sure what date it is:
http://dev.mysql.com/doc/refman/5.0/...on_date-format

However, would you wish to do it in PHP, look at these:
http://www.php.net/strtotime
http://www.php.net/date
http://www.php.net/strftime
--
Rik Wasmus
Oct 16 '07 #2
<comp.lang.ph p>
<Colleen Robledo, MLIS>
<Tue, 16 Oct 2007 07:42:28 -0000>
<11************ *********@e9g20 00prf.googlegro ups.com>
I'm still pretty new to PHP and MySQL, and have a PHP scripting
question.

If I'm querying DATE info from a MySQL database, and displaying it
with PHP echo statements... is there a PHP script I can use to convert
the DATE data to standard calendar format?

Example:

2007-10-12 displayed as October 12, 2007
<?php

$lager="2007-10-12";

$beer=explode('-',$lager);

$drink=date("F-d-Y",mktime(0,0,0 ,$beer[1],$beer[2],$beer[0]));

print "The converted date is $drink <br>";

?>
--
www.vhit.co.uk
www.jpgimage.co.uk
www.phpwhois.co.uk
www.cannabiswindow.co.uk
Oct 17 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
9449
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $ Last-Modified: $Date: 2003/10/28 19:48:44 $ Author: A.M. Kuchling <amk@amk.ca> Status: Draft Type: Standards Track
3
3232
by: Coco | last post by:
Hi! I managed to display chinese character in my web form (.aspx), in certain situation i need to to set the text of the label of my web form in chinese character programatically which is done in my code behind. when running the web form, the character which is entered directly to the web form during design time is displayed correctly, while those set from code behind appear as funny character
8
524
by: Chris Dunaway | last post by:
When using a PropertyGrid, I have an object with a Date property, but I am only interested in the Time portion. How do I make the PropertyGrid allow editing the time only? Just the hours and minutes, preferably? Thanks -- Chris dunawaycsbcglobal_lunchmeat_net
2
1147
by: Patrick Olurotimi Ige | last post by:
3/4/2005 5:50:08 PM Normally i display the above time and Date above from Database by using :- <%= DateTime.Parse(dr.ToString()).ToShortDateString() %><br/> <%= DateTime.Parse(dr.ToString()).ToShortTimeString() %> Any ideas how to display them together without having to seperate them as i have done above???
4
1429
by: KitKat | last post by:
Problem trying to figure this out, using a combo box selection I need to go to each folder, Cam 1, Cam 2, Cam 4, Cam 6, Cam 7,and Cam 8 and display each picture (from selection) from each folder and display in pictureboxes pcbCam1, pcbCam2, pcbCam4, pcbCam6, pcbCam7, and pcbCam8. So far the code works for one picture box not the others. Also when I reenter a different date the counter (+1) messes up....HELP
15
1519
by: Kevin Hanken | last post by:
Hi, Pretty much a newbie to aspnet and xp -- I am using XP Pro, Service Pack 2. I installed IIS, set up a virtual directory, created an aspx file and pasted in a little code from the w3schools site and then tried viewing the page using my localhost. The aspx page loads, but the little aspnet script asking to write the NOW function -- won't display. Since I copied it from w3schools, I am assuming
2
1310
by: mzmishra | last post by:
Hi, I have one requirement to display only the Date part of a DateTime column in datagrid. My DateTime column may contain null values also. My concern is while inserting the value into the table ,I am using it as DateTime.Now.Date but it stores the values as "29/08/2007 00:00:00". I only want 29/08/2007 in my datagrid. How to do that?If I can insert 29/08/2007 only ,it will also help me. Please suggest
10
2390
by: kyosohma | last post by:
Hi, I am working on a timesheet application in which I need to to find the first pay period in a month that is entirely contained in that month to calculate vacation time. Below are some example date ranges: December 31, 2006 January 13, 2007 # doesn't earn January 14, 2007 January 27, 2007 # does earn January 28, 2007 February 10, 2007 # doesn't
0
16512
yasirmturk
by: yasirmturk | last post by:
Standard Date and Time Functions The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any formatting considerations at all. They are simple, easy, and brief and you should use them any time you need to incorporate any date literals or date math in your T-SQL code. create function DateOnly(@DateTime DateTime) -- Returns @DateTime...
0
9555
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10515
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10260
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9100
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6827
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5616
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4156
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2956
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.