I recently took a job doing PHP but come from an ASP background. I'm
trying to find a conversion equivalent for VBScript's "formatdatetime ".
All I want to do is convert a MySQL datetime field into a long date.
e.g. 2006-01-30 to January 1, 2006.
PLEASE provide an example that I can use as a future benchmark so I can
understand the syntax better. I really need to learn PHP and I'm a
little freaked out right now.
Thanks! 10 3558
John K wrote: I recently took a job doing PHP but come from an ASP background. I'm trying to find a conversion equivalent for VBScript's "formatdatetime ".
All I want to do is convert a MySQL datetime field into a long date. e.g. 2006-01-30 to January 1, 2006.
PLEASE provide an example that I can use as a future benchmark so I can
understand the syntax better. I really need to learn PHP and I'm a little freaked out right now.
Thanks!
2006-01-30 can be converted to "January 1, 2006" using
date("F j, Y",mktime(0,0,0 ,01,30,2006));
Or, you can accomplish the same task with variables stuck into the mktime
function:
date("F j, Y",mktime($hour ,$minute,$secon d,$month,$day,$ year));
Kevin http://www.php.net/manual/en/ is a great place to start learning PHP.
Also, they have a function search on that page which allows you to
search for functions... The search input field has an auto-complete
feature to help you find the function you wish to locate.
Good Luck at your new job!
Scot
John K wrote: I recently took a job doing PHP but come from an ASP background. I'm trying to find a conversion equivalent for VBScript's "formatdatetime ".
All I want to do is convert a MySQL datetime field into a long date. e.g. 2006-01-30 to January 1, 2006.
PLEASE provide an example that I can use as a future benchmark so I can
understand the syntax better. I really need to learn PHP and I'm a little freaked out right now.
Thanks!
--
Scot McConnaughay
This is how I'm trying to do this at the moment, I should have included
this first, sorry.
<?php require_once('C onnections/hthConnect.php' ); ?>
<?php
mysql_select_db ($database_hthC onnect, $hthConnect);
$query_gigRecal l = "SELECT tbl_gigs.fld_gi g_Date,
tbl_gigs.fld_gi g_Time, tbl_gigs.fld_gi g_Title, tbl_gigs.fld_gi g_Place
FROM tbl_gigs WHERE tbl_gigs.fld_gi g_Date >= CURDATE()";
$gigRecall = mysql_query($qu ery_gigRecall, $hthConnect) or
die(mysql_error ());
$row_gigRecall = mysql_fetch_ass oc($gigRecall);
$totalRows_gigR ecall = mysql_num_rows( $gigRecall);
?>
<span class="midYello wCaps"><?php echo $row_gigRecall['fld_gig_Title'];
?></span><br>
HERE WHERE I'M TRYING TO FORMAT THE DATE BELOW
<?php echo $row_gigRecall['fld_gig_Date']; ?> at <?php echo
$row_gigRecall['fld_gig_Time']; ?>
John K wrote: This is how I'm trying to do this at the moment, I should have included this first, sorry.
<?php require_once('C onnections/hthConnect.php' ); ?> <?php mysql_select_db ($database_hthC onnect, $hthConnect); $query_gigRecal l = "SELECT tbl_gigs.fld_gi g_Date, tbl_gigs.fld_gi g_Time, tbl_gigs.fld_gi g_Title, tbl_gigs.fld_gi g_Place FROM tbl_gigs WHERE tbl_gigs.fld_gi g_Date >= CURDATE()"; $gigRecall = mysql_query($qu ery_gigRecall, $hthConnect) or die(mysql_error ()); $row_gigRecall = mysql_fetch_ass oc($gigRecall); $totalRows_gigR ecall = mysql_num_rows( $gigRecall); ?> <span class="midYello wCaps"><?php echo $row_gigRecall['fld_gig_Title']; ?></span><br> HERE WHERE I'M TRYING TO FORMAT THE DATE BELOW <?php echo $row_gigRecall['fld_gig_Date']; ?> at <?php echo $row_gigRecall['fld_gig_Time']; ?>
Why not just retrieve the date in that format with the query? http://dev.mysql.com/doc/refman/5.0/...functions.html
SELECT
DATE_FORMAT('%M %e, %Y',tbl_gigs.fl d_gig_Date) as fld_gig_Date,
tbl_gigs.fld_gi g_Time, tbl_gigs.fld_gi g_Title, tbl_gigs.fld_gi g_Place
FROM tbl_gigs WHERE tbl_gigs.fld_gi g_Date >= CURDATE()
--
Justin Koivisto, ZCE - ju****@koivi.co m http://koivi.com
"John K" <ki*****@yahoo. com> kirjoitti
viestissä:11*** *************** ****@f14g2000cw b.googlegroups. com... I recently took a job doing PHP but come from an ASP background. I'm trying to find a conversion equivalent for VBScript's "formatdatetime ".
All I want to do is convert a MySQL datetime field into a long date. e.g. 2006-01-30 to January 1, 2006.
$unixTimeStamp = strtotime('2006-01-30');
date('F d, Y', $unixTimeStamp) ;
Returns January 30, 2006
--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.ber keley.edu/>
Kimmo Laine <an************ *******@gmail.c om.NOSPAM.inval id>
I tried it didn't produce a result (the date that is). Time produced
result however.
This is what I put in. Did I do something wrong?
<?php
mysql_select_db ($database_hthC onnect, $hthConnect);
$query_gigRecal l = "SELECT DATE_FORMAT('%M %e,
%Y',tbl_gigs.fl d_gig_Date) as fld_gig_Date, tbl_gigs.fld_gi g_Time,
tbl_gigs.fld_gi g_Place FROM tbl_gigs";
$gigRecall = mysql_query($qu ery_gigRecall, $hthConnect) or
die(mysql_error ());
$row_gigRecall = mysql_fetch_ass oc($gigRecall);
$totalRows_gigR ecall = mysql_num_rows( $gigRecall);
?>
John K wrote: I tried it didn't produce a result (the date that is). Time produced result however.
This is what I put in. Did I do something wrong?
<?php mysql_select_db ($database_hthC onnect, $hthConnect); $query_gigRecal l = "SELECT DATE_FORMAT('%M %e, %Y',tbl_gigs.fl d_gig_Date) as fld_gig_Date, tbl_gigs.fld_gi g_Time, tbl_gigs.fld_gi g_Place FROM tbl_gigs"; $gigRecall = mysql_query($qu ery_gigRecall, $hthConnect) or die(mysql_error ()); $row_gigRecall = mysql_fetch_ass oc($gigRecall); $totalRows_gigR ecall = mysql_num_rows( $gigRecall); ?>
maybe it has to do with the name... try this instead:
DATE_FORMAT('%M %e, %Y',tbl_gigs.fl d_gig_Date) as formatGigDate
and then:
<?php echo $row_gigRecall['formatGigDate']; ?>
--
Justin Koivisto, ZCE - ju****@koivi.co m http://koivi.com
THAT DID IT, THANK YOU!!!! YES! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jay |
last post by:
I previously posted this question under Visual Basic
newsgroup, but was advised to re-post here.
I'm hoping someone can help me solve an issue I'm having
with VB.Net and Access 2000.
Here's the issue. I hope I've included all relevant
information.
On a form, I have a DateTimePicker with the following
|
by: Thomas Scheiderich |
last post by:
I have the following page as test.aspx:
***************************************************
<html>
<head>
<title>Hello and Welcome Page</title>
</head>
<body>
<center>
<%
Dim CurrentDate As String
|
by: Sune |
last post by:
Hi,
Is there any way to define the default date/time format, instead of having
to format every single time you print a date/time?
Thanks
--
Regards,
Sune
|
by: DC Gringo |
last post by:
How can I convert this pubLatest to a date with format "m/d/yyyy"?
Dim pubLatest As New Date
pubLatest = Me.SqlSelectCommand1.Parameters("@pubLatest").Value
--
_____
DC G
|
by: John K |
last post by:
I posted on this a week or so ago and found a resolution in that
instance by using DATE_FORMAT in my sql string to display the format I
was looking for. This time I need to format the date going "into" the
database. In ASP/VBScript I just use "FormatDateTime" to convert the
users input into a palatable MySQL "date" datatype.
Here's what I...
| |
by: fiefie.niles |
last post by:
I set my computer Regional Setting (Control Panel - Regional and
Language Options - Customize - Date) to dd/mm/yy. In my ASP page I do
the following:
FormatDateTime("1/20/07",2)
and it returns 1/20/07 instead of 20/1/07.
I though my setting it to 2, it will display a date using the short
date format specified in your computer's...
|
by: nitinkeser |
last post by:
how i convert date into specific format in asp?
like in date format 'Jun 17, 2007' ?
|
by: janetopps |
last post by:
This is an asp page which adds a template to a mysql database. it returns this error
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'FormatDateTime'
/temps.asp, line 111
|
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
| |
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |