views:

213

answers:

3

Hi all, I'm using GoDaddy's Shared Linux hosting.

Using php i am inserting or updating the mysql database with create date or modified date using the variables
$datestring = "%Y:%m:%d %h:%i:%s";
$time = time();
$createdate= mdate($datestring, $time);

In this $createdate will be the variable i use to insert or update the table. But its updating the wrong value. ITs not the server time or localtime. mostly its 30 mins delay with godaddy's server time.

Pls help.

A: 

Edit: after some googling it looks like you're using CodeIgniter. You should have mentioned that in your question.

The format string you're using doesn't match MySQL's date format. You want to use:

$datestring = '%Y-%m-%d %H:%i:%s';
Chad Birch
Sorry for not mentioning i am using codeigniter. Anyway thanks for pointing. :)
ASD
A: 

use in mysql query like DATE_FORMAT(purchaseDate, "%Y:%m:%d %h:%i:%s") function

sam
+1  A: 

Use date function of php

$createdate= date('Y-m-d H:i:s');
Veer