Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    Regular Coder
    Join Date
    Dec 2009
    Posts
    243
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Why Is My Date Not Being Display Correctly?

    Alright guys

    I am wondering why is the date not be displayed properly on this page please http://www.digitalresellersvault.com...e_Label_Rights

    Let me start from the top

    I have added a javascript date picker, and text box to the add products.html page.. Here is the code for that bit

    Code:
    <input type="text" name="product_date" value="{{product_date}}" id="date" size="20" /> 
    <script>
    		$('#date').datepicker();
    		</script>
    I know that bit works because it allows me to select whatever date I want and then it is showed in the text box..

    I have then linked that text box to a field on a mysql database called product_date using these two pieces of code. The field is in date format

    Code:
    $product_date                   = $_POST["product_date"];  
    $set .= "product_date           = '$product_date',";
    The marketplace.php is used for the layout of the site.. The following code tells the page what to load up

    Code:
    $GetFile = file("http://www.digitalresellersvault.com/template/template.php");
    	$Content = join("", $GetFile);
    	$categories=$common->categories($db);
    	$content=str_replace("{categories}",$categories,$content);	
    	$Pat = "/<{Begin}>(.*?)<{End}>/s";
    	preg_match($Pat,$Content,$Output);
    	$SelectedContent = $Output[1];
    	$q = "select * from ".$prefix."products where show_product = '1' ORDER BY Rand() LIMIT 1";
    	$r = $db->get_a_line($q);
    	$id = $r[id];
    	$imageurl = $r[imageurl];
    	$prod_description = $r[prod_description];
    	$salesprice = $r[price];
    	$product_name = $r[product_name];
    	$licence = $r[licence];
    	$product_date = $r[product_date];
    	$salespage_link='<a href="prods.php?pid='.$id.'"><img border="0" src="http://www.digitalresellersvault.com/template/images/moreinfobutton.jpg" width="104" height="16"></a>';
    As stated before I can choose and date and then stored in on the database.. But for some reason I can not get the date to be displayed.. I can only get the 0000-00-00 to display..

    I am a little bit confused

  • #2
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Quote Originally Posted by Byronwells View Post
    As stated before I can choose and date and then stored in on the database.. But for some reason I can not get the date to be displayed.. I can only get the 0000-00-00 to display..

    I am a little bit confused
    What value is in the DB? When I get 0000-00-00 it was because the INSERT query was wrong for the date column and I ended up with 0000-00-00 inserted into the DB.



    -----------
    Leonard Whistler

  • #3
    Regular Coder
    Join Date
    Dec 2009
    Posts
    243
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Len Whistler View Post
    What value is in the DB? When I get 0000-00-00 it was because the INSERT query was wrong for the date column and I ended up with 0000-00-00 inserted into the DB.



    -----------
    What do you mean value?? All I did was create a field called it product_date, chose the date type and that is it..

    What else am I suppose to do?

  • #4
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Quote Originally Posted by Byronwells View Post
    What do you mean value?? All I did was create a field called it product_date, chose the date type and that is it..

    What else am I suppose to do?
    What does the date look like in the date column? If you enter February 1, 2010 it will end up like 0000-00-00. It must be entered as YYYY-MM-DD.


    ------
    Leonard Whistler

  • #5
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi.. Byronwells.

    You can try with the different date function to solve out your problem.
    Another reason may be your system Date/time is not correctly set so it may saw you wrong date.


    -------------------------------

    ClickSSL.com

  • #6
    Regular Coder
    Join Date
    Dec 2009
    Posts
    243
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Len Whistler View Post
    What does the date look like in the date column? If you enter February 1, 2010 it will end up like 0000-00-00. It must be entered as YYYY-MM-DD.


    ------
    Len oh right.. I used the defualt setting, which is 0000-00-00 I didnt realised that I could change it the db field

  • #7
    Regular Coder
    Join Date
    Dec 2009
    Posts
    243
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by langdon4487 View Post
    Hi.. Byronwells.

    You can try with the different date function to solve out your problem.
    Another reason may be your system Date/time is not correctly set so it may saw you wrong date.


    -------------------------------

    ClickSSL.com
    The date is stored in the text box like this

    02/15/2010 0 MM-DD-YYYY

    I have attempted to change the product_date vaule field to that format.. But it still displays the 0000-00-00 format even in the db field and on the site.. I have deleted the field and start fresh, and it stil does the same...

    Do I need some code like this?
    $_POST['date'] = date('Y-m-d', strtotime($_POST['date']));"

  • #8
    Regular Coder
    Join Date
    Dec 2009
    Posts
    243
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by langdon4487 View Post
    Hi.. Byronwells.

    You can try with the different date function to solve out your problem.
    Another reason may be your system Date/time is not correctly set so it may saw you wrong date.


    -------------------------------

    ClickSSL.com
    Alright Langdon

    I am trying at the moment to play around with different date functions. I have attempted to change the vaule of the product_date to read mm-dd-year, but it still displaying in 0000-00-00

  • #9
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Quote Originally Posted by Byronwells View Post
    The date is stored in the text box like this

    02/15/2010 0 MM-DD-YYYY

    The mysql date must be entered as YYYY-MM-DD, otherwise you end up with 0000-00-00. You will need to create a PHP function to format the input properly.



    ----------
    Last edited by Len Whistler; 02-02-2010 at 07:50 PM.
    Leonard Whistler

  • #10
    Regular Coder
    Join Date
    Dec 2009
    Posts
    243
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Len Whistler View Post
    The mysql date must be entered as YYYY-MM-DD, otherwise you end up with 0000-00-00. You will need to create a PHP function to format the input properly.



    ----------
    Len

    I have got the numerical date to appear now.. see here...
    http://www.digitalresellersvault.com...egory=Dec_2008

    What I am about to attempt now is to take the month numerical date and turn it words.. i.e dec/02/2010

  • #11
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    This will take a mysql date column.
    PHP Code:
    $formattedDate date("F d, Y g:i a",strtotime($row["time_stamp"])); 
    And output this:
    Code:
    January 02, 2010 4:02 pm EST



    ---------
    Leonard Whistler

  • #12
    Regular Coder
    Join Date
    Dec 2009
    Posts
    243
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Len Whistler View Post
    This will take a mysql date column.
    PHP Code:
    $formattedDate date("F d, Y g:i a",strtotime($row["time_stamp"])); 
    And output this:
    Code:
    January 02, 2010 4:02 pm EST



    ---------
    Len

    If I am using the product_date field.. how do I GET the adove code to be linked to that one please??

    And thank you for your help

  • #13
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    With a msql query. Untested, might be syntax errors.

    PHP Code:
    $sql mysql_query("SELECT * FROM db_table_name");

    while(
    $row mysql_fetch_array($sql)){
    $formattedDate date("F d, Y g:i a",strtotime($row["date_column"]));
    echo 
    "$formattedDate";
    //  echo other mysql data



    ----
    Leonard Whistler

  • #14
    Regular Coder
    Join Date
    Dec 2009
    Posts
    243
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Len Whistler View Post
    This will take a mysql date column.
    PHP Code:
    $formattedDate date("F d, Y g:i a",strtotime($row["time_stamp"])); 
    And output this:
    Code:
    January 02, 2010 4:02 pm EST



    ---------
    Len

    I do apologise for being a pain

    I have been told by someone that I need to put the following code in the add_products.php

    "With regards to the 0000-00-00 check that the date being sent to the server is in the correct format. To be safe, it should be in the format 'Y-m-d'. You can use something like "$_POST['date'] = date('Y-m-d', strtotime($_POST['date']));" where 'date' is the name of the date input element."

    But I am not sure exactly where...

  • #15
    New to the CF scene
    Join Date
    Nov 2010
    Location
    United Kingdom
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There is a WordPress knowledge base file that explains all the different date format types.

    http://codex.wordpress.org/Formatting_Date_and_Time

    which to me explains all the varying date formats perfectly.

    -------------------------------

    SSL Certs


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •