Douglas28 Posted November 22, 2011 Share Posted November 22, 2011 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 More sharing options...
unlishema.wolf Posted November 22, 2011 Share Posted November 22, 2011 use this to get the correct date/time format you are wanting. date('Y-m-d H\:i\:s.u') Link to comment https://forums.phpfreaks.com/topic/251648-php-datetime-1900-01-24-000000000/#findComment-1290608 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.