Hi everyone. I am trying to make a table that when people edit something from it, it will show the date it was edited.
This is my code:
[PHP]$date = date("m/d/Y");
mssql_query("IN SERT INTO news2 (title, dtime, text1, text2) VALUES ('$title', $date, '$text1', '$text2')");[/PHP]
The thing is that when I check the table, the time is messed up. It shows 4/11/1900 instead of 01/20/2008.
And if its possible, is there a way I could change the format of the date at the MSSQL? I need something like this:12:55 01/20/2008.
Btw, the data type of the column is datatime.
Thank you
~ SalokinX
6 4755
Hi everyone. I am trying to make a table that when people edit something from it, it will show the date it was edited.
This is my code:
[PHP]$date = date("m/d/Y");
mssql_query("IN SERT INTO news2 (title, dtime, text1, text2) VALUES ('$title', $date, '$text1', '$text2')");[/PHP]
The thing is that when I check the table, the time is messed up. It shows 4/11/1900 instead of 01/20/2008.
And if its possible, is there a way I could change the format of the date at the MSSQL? I need something like this:12:55 01/20/2008.
Btw, the data type of the column is datatime.
Thank you
~ SalokinX
The reason why it is showing up this way is because you are formating it for the month, day, year with date("m/d/Y"). In your insert statement you could just use 'now()' instead of '$date'.
Markus 6,050
Recognized Expert Expert
how about:
[php]
<?php
echo date("h:m m/d/Y")
?>
[/php]
The reason why it is showing up this way is because you are formating it for the month, day, year with date("m/d/Y"). In your insert statement you could just use 'now()' instead of '$date'.
I tried the 'now()' and I get this error: Warning: mssql_query() [function.mssql-query]: message: Syntax error converting datetime from character string. (severity 16) in C:\xampp\htdocs \news2.php on line 22
Warning: mssql_query() [function.mssql-query]: Query failed in C:\xampp\htdocs \news2.php on line 22
I think I know what it means, but I have no idea how to fix it. Any ideas?
And does anyone know how I could change the date format on MSSQL? I wanted it to be like this: 12:45 30/12/2008
Thank you
~ SalokinX
Anyone?
Please, this is urgent.
Thank you!
~ SalokinX
I fixed the problem... I used a pretty longer code, but it worked.
[PHP] $dia = gmdate(d);
$mes = gmdate(m);
$ano = gmdate(Y);
$minuto = gmdate(i);
$date = gmdate(H);
$brdate = $date - 2;
$brdate2 = $brdate;
if($brdate < 0)
{
$brdate2 = $brdate + 12;
$ampm = "PM";
}
elseif($brdate == 0)
{
$brdate2 = $brdate + 12;
$ampm = "AM";
}
elseif($brdate <= 11)
{
$ampm = "AM";
}
elseif($brdate == 12)
{
$brdate2 == $brdate;
$ampm = "PM";
}
elseif($brdate >= 13)
{
$brdate2 = $brdate - 12;
$ampm = "PM";
}
if($brdate2 < 10)
{
$hora = "0$brdate2:$min uto$ampm";
}
else
{
$hora = "$brdate2:$minu to$ampm";
}
$adddate = "$hora $dia/$mes/$ano";[/PHP]
code green 1,726
Recognized Expert Top Contributor
You were getting the NOW error because you were probably enclosing the function in quotes - SET DATE = 'NOW()' is wrong, should be
-
SET DATE = NOW()
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: lawrence |
last post by:
I haven't been able to reach www.php.net for days. Most of the rest of
the web is working for me, though I've bad trouble reaching any
English sites. Anyone else having trouble?
|
by: English Teacher |
last post by:
Which would be more useful to learn, PHP or COLDFUSION? I know
Coldfusion is popular in the work force. Is PHP?
Thanks!
|
by: Lennart Björk |
last post by:
Hi All,
I have a tiny program:
<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>MyTitle</title>
<meta http-equiv="Content-Type" content="text/html;
|
by: jdurden |
last post by:
am currently woking on building this site: www.maverick-spirit.com.
everything seems to be fine except the press releases page. When you
click on one of the press releases in the left column under the menu,
nothing comes up. I copied the code for the page directly from the
press releases page on our main site: www.maverickentertainment.cc, and
it is using an identical database, so I am unsure what is wrong.
The issue happens when you...
|
by: ansc1 |
last post by:
Hello, I'm new to using php coding. I need help with the following:
1. There is a submit button on the form and is saves information to
my database. After clicking on "Save Measurement" it redirects me to
another page in my site.
What I would like to do is change what page directs it to. Currently
the submit button redirects me to page /measure/men_measure. I would
like to be able to change this.
Please see below my page below:...
| |
by: Benjamin Grieshaber |
last post by:
Hi,
I´m on SuSE 9.3 with xmlrpc-c and xmlrpc-c-devel installed (ver. 0.9.10)
I tried to compile php with xmlrpc support and got the following errors:
ext/xmlrpc/.libs/xmlrpc-epi-php.o(.text+0x359): In function
`set_zval_xmlrpc_type':
/php-5.2.5/ext/xmlrpc/xmlrpc-epi-php.c:1313: undefined reference to
`XMLRPC_CreateValueDateTime_ISO8601'
|
by: mekalai82 |
last post by:
i have information.php file that file contain following coding <?php
echo phpinfo(); ?>
while i calling the URL ("http://localhost/information.php").
i am getting the coding <?php echo phpinfo(); ?>
not show the php information...... i am new to the php can you help me?
|
by: Patriot89 |
last post by:
I have a quick question in reference to php file extenstions...
I have code for example like this... This is all located on this site www.ixalliance.com/BHS/Default
(This is my nav.php file)
<div class="navstyle" id="navmenu">
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="administration/admin.php" rel="dropmenu1">Administration</a></li>
|
by: mechphisto |
last post by:
I'm working on a friend's box, Fedora Core 6. It has PHP 5.1.6.
I need to install mcrypt into it, and the only way I can find to do it
is from source then recompile PHP. So I did all that, and got the
latest PHP, 5.2.5.
The ./configure finally went through OK. Make and make install. Then I
restarted Apache...
but the phpinfo() shows no change. It's still using 5.1.6.
When I run "php -v" from command line I get a huge error I'll include...
|
by: Chrisjc |
last post by:
Good afternoon,
I am seeking some php configuration help. Here is the run down I am running Windows server 2003 and IIS V6.0 I have never had issues before until now. I have Symantec Antivirus 11.0 Manager, it controls all the Symantec clients in the company.
Now it uses a web interface for all of its commands and settings which is called (SEPM) This reporting unit uses php, Symantec by default is loading its php.ini from “C:\Program...
|
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,...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
| |
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |