473,320 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to fix my date problem

123 100+
the code below is met to insert the variable u_date to my table and echo it but when ever i echo the date from the table i select it, it's not also correct ever when my system date is correct and secondly i want the date should look like this 10-June-2010 not like this 10-6-2010.

Expand|Select|Wrap|Line Numbers
  1. $name= ($_POST['name']);
  2. $u_date = date ('h.m.Y');
  3.  
  4. mysql_query("INSERT INTO user
  5. (name, u_date) VALUES('" . $name . "', '" . $u_date. "')
  6.  
  7. i select the date from user and echo but the date is not correct
  8.  
Oct 26 '10 #1
3 1589
dlite922
1,584 Expert 1GB
mySQL date format is yyyy-mm-dd. You must insert it this way.

How you want to display it, that's another story. Database is for storage, not for display.

What's your table definition like? is it a varchar or datetime?

i select the date from user and echo but the date is not correct
That doesn't tell me much. Where's the code? what's not correct about it? how much is it off by?


Dan
Oct 26 '10 #2
simon2x1
123 100+
what i want is this the date variable which i insert and select back in my table to echo should display the correct date like today date is 2005-10-27 when i insert the variable date and select to echo it display this 2012-10-20 also my U_date field i choose date for the type lastly how can i make the date to look like this 10-June-2010 not like this 10-6-2010
Expand|Select|Wrap|Line Numbers
  1.  $name= ($_POST['name']);
  2.  $u_date = date ('h.m.Y');
  3.  
  4.  mysql_query("INSERT INTO user
  5.  (name, u_date) VALUES('" . $name . "', '" . $u_date. "')
  6.  
  7. $query1 = "SELECT * FROM user";
  8. $result1 = mysql_query ($query1) or die('query error');
  9. $line = mysql_fetch_assoc($result1);
  10.  
  11. $d_user = $line[name];
  12. $d_date = $line[u_date];
  13.  
  14. echo"$d_user<br>$d_date";
  15.  
Oct 27 '10 #3
simon2x1
123 100+
what i want is this the date variable which i insert and select back in my table to echo should display the correct date like today date is 2005-10-27 when i insert the variable date and select to echo it display this 2012-10-20 also my U_date field i choose date for the type lastly how can i make the date to look like this 10-June-2010 not like this 10-6-2010
Expand|Select|Wrap|Line Numbers
  1.  $name= ($_POST['name']);
  2.  $u_date = date ('h.m.Y');
  3.  
  4.  mysql_query("INSERT INTO user
  5.  (name, u_date) VALUES('" . $name . "', '" . $u_date. "')
  6.  
  7. $query1 = "SELECT * FROM user";
  8. $result1 = mysql_query ($query1) or die('query error');
  9. $line = mysql_fetch_assoc($result1);
  10.  
  11. $d_user = $line[name];
  12. $d_date = $line[u_date];
  13.  
  14. echo"$d_user<br>$d_date";
  15.  
Oct 27 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Dominique Javet | last post by:
Hello, I'm new to php and mysql and I use Dreamweaver MX 2004, so sorry for this "newbie" question... I've found no answer in the forum ... I've a date problem with my formular. In my mysql DB...
1
by: OzThor | last post by:
ok, re my post about using date's to load differen .js files... thanks... have it working now.... well almost.... I have a quiz here that loads a new set of questions each day... the...
7
by: Andy Davis | last post by:
I have a table of data in Access 2002 which is used as the source table for a mail merge document using Word 2002 on my clients PC. The data is transferred OK but I've noticed that any dates which...
0
by: Luis Esteban Valencia | last post by:
Hi, I am using windows 2000 Pro with SP4 for development and database is access2000. Regional Setting is as follows: Regional Options: Your locale(location): English United States short date...
0
by: Arpicheck | last post by:
Hi, I am writing a page that contains a texbox, a calendar, and a rangevalidator. The range validator is testing the textbox for date values. There is an event, set up to fire, when the...
3
by: seegoon | last post by:
Hi to all. I have a small problem I hope someone can help me with. I am running a sql query to a csv file. The query searches for the total of a column between 2 dates. This is a copy of one of...
15
by: edouard.spooner | last post by:
Hi, I have a tricky SQL query problem that I'm having probs with. I have a table which resembles something like this Date | Price1 | Price2 | Price3 01 Jan 2006 | 100 | 100 | 100 02 Jan...
2
by: hardik | last post by:
hi friends, i am really surprized the way access behaves in date fields i mean it's all ok when you have us time zone or us servers but if you have diffrent timezone like uk then access creates...
0
by: mykhan | last post by:
I have been using access database with asp.net pages. I just realized a problem with date saving in access table. I didnt give any specific format for the date when saved in tables, because I wanted...
3
by: Neil Chinneck | last post by:
Hi everyone, I have a weird problem, and I cannot work out what's going on. I have a continuous form (frmEnterCosts) based on a query (qryEnterCosts). I have series of unbound combo boxes to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.