Jump to content

PHP Datetime 1900-01-24 00:00:00.000


Douglas28

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.