Page 1 of 1

DATE function - Space problem

Posted: Thu Dec 28, 2006 4:45 pm
by vamsinadella
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi,

I need  to populate a text filed with todays date. As simple it is, i use date('Y m d h:m:s'). BUT THIS won't work. If i remove the spaces between the attributes, then it works fine. or i have to put a '-' between them. Well, the '-' works fine for date, like: 2005-12-28, but what can i do for the space i NEED between time and date. Currently i'm using a '.' and it looks awkward. Somehing like: 2006-12-28.02:41:32(notice the '.' between date and time). I just want to eliminate the '.' and use a space, but it's not letting me. I have never seen this problem. I know i'm doing something wrong. Can anyone throw some intel info on this?

code snippet:

Code: Select all

<?php
 $today = date('Y-m-d.h:m:s');
 echo $today;
?>
Help is greatly appreciated.....Thanks.

- Vamz


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Dec 28, 2006 4:51 pm
by feyd
Tag attribute values must be contained in quotes.

Posted: Thu Dec 28, 2006 5:03 pm
by Kieran Huggins
Good catch, feyd! I didn't even get what you were saying for a minute.

For vamsinadella's reference: he means in the html input element, not in PHP:

Code: Select all

<input name="date" value="<?=date('Y m d h:m:s')?>" />