Jump to content

Recommended Posts

SQL Server keeps showing my DateTime as

1900-01-24 00:00:00.000
in the actual database. 

 

I'm baffeled at this.  My PHP Cookbook gives me different solutions like

localtime()

, but nothing seems to work.

 

I use Stored Procedures for SQL Server - as you do.  My Stored Procedure is below:

 

USE [FortissimoMedia]
GO
/****** Object:  StoredProcedure [dbo].[insertHome]    Script Date: 11/22/2011 23:21:37 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[insertHome] (

@PostContent TEXT,
@PostAuthor TEXT,
@DatePosted datetime,
@IP TEXT

)

AS

INSERT INTO tblHome (PostContent, PostAuthor, DatePosted, IP)
VALUES
(@PostContent, @PostAuthor, @DatePosted, @IP)

 

And my PHP code is below:

 


$con = mssql_connect(".\SQLExpress", "Username", "Password");  // hidden for obvious reasons
mssql_select_db("FortissimoMedia", $con);
$stmt = mssql_init("InsertHome", $con);
mssql_bind($stmt, '@PostContent', $_POST["PostContent"], SQLTEXT, false, false);
mssql_bind($stmt, '@PostAuthor', $PostAuthor, SQLTEXT, false, false);
mssql_bind($stmt, '@DateAdded', date("Y-m-d", time()), SQLDATETIME, false);
mssql_bind($stmt, '@IP', $_SERVER["REMOTE_ADDR"], SQLTEXT, false, false);
mssql_execute($stmt);

 

Maybe it's just cause I didn't get enough sleep last night or I might not be doing something right.  Hope someone can advise me. 

 

Thank you

 

Douglas

 

Link to comment
https://forums.phpfreaks.com/topic/251648-php-datetime-1900-01-24-000000000/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.