Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

SQL date in PHP?

LEGEND ,
Feb 15, 2007 Feb 15, 2007
I have a SQL date field. I want to insert the current date and time into
it. What format option would I use for the PHP date() function?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================



TOPICS
Server side applications
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
Murray *ACE* wrote:
> I have a SQL date field. I want to insert the current date and time into
> it. What format option would I use for the PHP date() function?

If you want to insert the current date and time in MySQL, just use the
NOW() function.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
That'll work with the SQL Date field?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:er21jr$qhv$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> I have a SQL date field. I want to insert the current date and time into
>> it. What format option would I use for the PHP date() function?
>
> If you want to insert the current date and time in MySQL, just use the
> NOW() function.
>
> --
> David Powers, Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> Author, "PHP Solutions" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
I want to load a form with the value of the date and time to be inserted
into a Date field in MySQL. That's the scenario.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:er21jr$qhv$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> I have a SQL date field. I want to insert the current date and time into
>> it. What format option would I use for the PHP date() function?
>
> If you want to insert the current date and time in MySQL, just use the
> NOW() function.
>
> --
> David Powers, Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> Author, "PHP Solutions" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
As David said, NOW() will work in the SQL as the field value.

Alternatively, if you want to use the PHP date command, the correct format
for date is:

date("Y-m-d")

date and time is:

date("Y-m-d H:i:s")

--
Gareth
http://www.phploginsuite.co.uk/
PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
If I insert a field containing date("Y-m-d H:i:s") as its value into a SQL
field with the Date format, will that work?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"gareth" <support@nospam_phploginsuite.co.uk> wrote in message
news:er226o$rb2$1@forums.macromedia.com...
> As David said, NOW() will work in the SQL as the field value.
>
> Alternatively, if you want to use the PHP date command, the correct format
> for date is:
>
> date("Y-m-d")
>
> date and time is:
>
> date("Y-m-d H:i:s")
>
> --
> Gareth
> http://www.phploginsuite.co.uk/
> PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
It does work, but the time value is truncated off?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:er22o1$s1s$1@forums.macromedia.com...
> If I insert a field containing date("Y-m-d H:i:s") as its value into a SQL
> field with the Date format, will that work?
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.dreamweavermx-templates.com - Template Triage!
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
> ==================
>
>
> "gareth" <support@nospam_phploginsuite.co.uk> wrote in message
> news:er226o$rb2$1@forums.macromedia.com...
>> As David said, NOW() will work in the SQL as the field value.
>>
>> Alternatively, if you want to use the PHP date command, the correct
>> format for date is:
>>
>> date("Y-m-d")
>>
>> date and time is:
>>
>> date("Y-m-d H:i:s")
>>
>> --
>> Gareth
>> http://www.phploginsuite.co.uk/
>> PHP Login Suite V2 - 34 Server Behaviors to build a complete Login
>> system.
>>
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
Are you doing this on the SQL Server table as in a Default Value for the
field?

If so the date should not be truncated .


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:er2319$sgg$1@forums.macromedia.com...
> It does work, but the time value is truncated off?
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.dreamweavermx-templates.com - Template Triage!
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
> ==================
>
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:er22o1$s1s$1@forums.macromedia.com...
>> If I insert a field containing date("Y-m-d H:i:s") as its value into a
>> SQL field with the Date format, will that work?
>>
>> --
>> Murray --- ICQ 71997575
>> Adobe Community Expert
>> (If you *MUST* email me, don't LAUGH when you do so!)
>> ==================
>> http://www.dreamweavermx-templates.com - Template Triage!
>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>> ==================
>>
>>
>> "gareth" <support@nospam_phploginsuite.co.uk> wrote in message
>> news:er226o$rb2$1@forums.macromedia.com...
>>> As David said, NOW() will work in the SQL as the field value.
>>>
>>> Alternatively, if you want to use the PHP date command, the correct
>>> format for date is:
>>>
>>> date("Y-m-d")
>>>
>>> date and time is:
>>>
>>> date("Y-m-d H:i:s")
>>>
>>> --
>>> Gareth
>>> http://www.phploginsuite.co.uk/
>>> PHP Login Suite V2 - 34 Server Behaviors to build a complete Login
>>> system.
>>>
>>
>>
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
I am inserting a form's data into a SQL table. One of the fields in the
table is a Date field. How do I format the field in the form using PHP so
that I get the date and time in that SQL date field?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"PizzaGood" <PizzaGood@earthlink.com> wrote in message
news:er23ig$t4f$1@forums.macromedia.com...
> Are you doing this on the SQL Server table as in a Default Value for the
> field?
>
> If so the date should not be truncated .
>
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:er2319$sgg$1@forums.macromedia.com...
>> It does work, but the time value is truncated off?
>>
>> --
>> Murray --- ICQ 71997575
>> Adobe Community Expert
>> (If you *MUST* email me, don't LAUGH when you do so!)
>> ==================
>> http://www.dreamweavermx-templates.com - Template Triage!
>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>> ==================
>>
>>
>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>> news:er22o1$s1s$1@forums.macromedia.com...
>>> If I insert a field containing date("Y-m-d H:i:s") as its value into a
>>> SQL field with the Date format, will that work?
>>>
>>> --
>>> Murray --- ICQ 71997575
>>> Adobe Community Expert
>>> (If you *MUST* email me, don't LAUGH when you do so!)
>>> ==================
>>> http://www.dreamweavermx-templates.com - Template Triage!
>>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>>> ==================
>>>
>>>
>>> "gareth" <support@nospam_phploginsuite.co.uk> wrote in message
>>> news:er226o$rb2$1@forums.macromedia.com...
>>>> As David said, NOW() will work in the SQL as the field value.
>>>>
>>>> Alternatively, if you want to use the PHP date command, the correct
>>>> format for date is:
>>>>
>>>> date("Y-m-d")
>>>>
>>>> date and time is:
>>>>
>>>> date("Y-m-d H:i:s")
>>>>
>>>> --
>>>> Gareth
>>>> http://www.phploginsuite.co.uk/
>>>> PHP Login Suite V2 - 34 Server Behaviors to build a complete Login
>>>> system.
>>>>
>>>
>>>
>>
>>
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
A DATE field holds just the date. If you want date and time change to the
DATETIME data type.

--
Gareth
http://www.phploginsuite.co.uk/
PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.



Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
I don't do PHP, but in ASP I use this as the default value of a hidden text
field on forms:

<input name="textfield" type="hidden" value="<%=now()%>">

and then I just insert the record. I only do this if I do not want the
actual server time, if I want the server time I set the default of the field
on the actual sql server table/field.

Would PHP be something like this?????

<!--#echo var="DATE_LOCAL"-->




"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:er2442$dc$1@forums.macromedia.com...
>I am inserting a form's data into a SQL table. One of the fields in the
>table is a Date field. How do I format the field in the form using PHP so
>that I get the date and time in that SQL date field?
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.dreamweavermx-templates.com - Template Triage!
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
> ==================
>
>
> "PizzaGood" <PizzaGood@earthlink.com> wrote in message
> news:er23ig$t4f$1@forums.macromedia.com...
>> Are you doing this on the SQL Server table as in a Default Value for the
>> field?
>>
>> If so the date should not be truncated .
>>
>>
>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>> news:er2319$sgg$1@forums.macromedia.com...
>>> It does work, but the time value is truncated off?
>>>
>>> --
>>> Murray --- ICQ 71997575
>>> Adobe Community Expert
>>> (If you *MUST* email me, don't LAUGH when you do so!)
>>> ==================
>>> http://www.dreamweavermx-templates.com - Template Triage!
>>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>>> ==================
>>>
>>>
>>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>>> news:er22o1$s1s$1@forums.macromedia.com...
>>>> If I insert a field containing date("Y-m-d H:i:s") as its value into a
>>>> SQL field with the Date format, will that work?
>>>>
>>>> --
>>>> Murray --- ICQ 71997575
>>>> Adobe Community Expert
>>>> (If you *MUST* email me, don't LAUGH when you do so!)
>>>> ==================
>>>> http://www.dreamweavermx-templates.com - Template Triage!
>>>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>>>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>>>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>>>> ==================
>>>>
>>>>
>>>> "gareth" <support@nospam_phploginsuite.co.uk> wrote in message
>>>> news:er226o$rb2$1@forums.macromedia.com...
>>>>> As David said, NOW() will work in the SQL as the field value.
>>>>>
>>>>> Alternatively, if you want to use the PHP date command, the correct
>>>>> format for date is:
>>>>>
>>>>> date("Y-m-d")
>>>>>
>>>>> date and time is:
>>>>>
>>>>> date("Y-m-d H:i:s")
>>>>>
>>>>> --
>>>>> Gareth
>>>>> http://www.phploginsuite.co.uk/
>>>>> PHP Login Suite V2 - 34 Server Behaviors to build a complete Login
>>>>> system.
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
Duh - that'd do it. Thanks!

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"gareth" <support@nospam_phploginsuite.co.uk> wrote in message
news:er24sb$1e4$1@forums.macromedia.com...
>A DATE field holds just the date. If you want date and time change to the
>DATETIME data type.
>
> --
> Gareth
> http://www.phploginsuite.co.uk/
> PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.
>
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
It works fine like this -

<input name="textfield" type="hidden" value="<?php date('Y-m-d H:i:s'); ?>"
/>

when that field is being inserted into a SQL DATETIME field.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"PizzaGood" <PizzaGood@earthlink.com> wrote in message
news:er252n$1j3$1@forums.macromedia.com...
>I don't do PHP, but in ASP I use this as the default value of a hidden text
>field on forms:
>
> <input name="textfield" type="hidden" value="<%=now()%>">
>
> and then I just insert the record. I only do this if I do not want the
> actual server time, if I want the server time I set the default of the
> field on the actual sql server table/field.
>
> Would PHP be something like this?????
>
> <!--#echo var="DATE_LOCAL"-->
>
>
>
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:er2442$dc$1@forums.macromedia.com...
>>I am inserting a form's data into a SQL table. One of the fields in the
>>table is a Date field. How do I format the field in the form using PHP so
>>that I get the date and time in that SQL date field?
>>
>> --
>> Murray --- ICQ 71997575
>> Adobe Community Expert
>> (If you *MUST* email me, don't LAUGH when you do so!)
>> ==================
>> http://www.dreamweavermx-templates.com - Template Triage!
>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>> ==================
>>
>>
>> "PizzaGood" <PizzaGood@earthlink.com> wrote in message
>> news:er23ig$t4f$1@forums.macromedia.com...
>>> Are you doing this on the SQL Server table as in a Default Value for the
>>> field?
>>>
>>> If so the date should not be truncated .
>>>
>>>
>>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>>> news:er2319$sgg$1@forums.macromedia.com...
>>>> It does work, but the time value is truncated off?
>>>>
>>>> --
>>>> Murray --- ICQ 71997575
>>>> Adobe Community Expert
>>>> (If you *MUST* email me, don't LAUGH when you do so!)
>>>> ==================
>>>> http://www.dreamweavermx-templates.com - Template Triage!
>>>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>>>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>>>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>>>> ==================
>>>>
>>>>
>>>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>>>> news:er22o1$s1s$1@forums.macromedia.com...
>>>>> If I insert a field containing date("Y-m-d H:i:s") as its value into a
>>>>> SQL field with the Date format, will that work?
>>>>>
>>>>> --
>>>>> Murray --- ICQ 71997575
>>>>> Adobe Community Expert
>>>>> (If you *MUST* email me, don't LAUGH when you do so!)
>>>>> ==================
>>>>> http://www.dreamweavermx-templates.com - Template Triage!
>>>>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>>>>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>>>>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>>>>> ==================
>>>>>
>>>>>
>>>>> "gareth" <support@nospam_phploginsuite.co.uk> wrote in message
>>>>> news:er226o$rb2$1@forums.macromedia.com...
>>>>>> As David said, NOW() will work in the SQL as the field value.
>>>>>>
>>>>>> Alternatively, if you want to use the PHP date command, the correct
>>>>>> format for date is:
>>>>>>
>>>>>> date("Y-m-d")
>>>>>>
>>>>>> date and time is:
>>>>>>
>>>>>> date("Y-m-d H:i:s")
>>>>>>
>>>>>> --
>>>>>> Gareth
>>>>>> http://www.phploginsuite.co.uk/
>>>>>> PHP Login Suite V2 - 34 Server Behaviors to build a complete Login
>>>>>> system.
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
OK...hopefully I was able to help in some way because I REALLY APPRECIATE
all the help you have given me over time.




"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:er2615$2od$1@forums.macromedia.com...
> It works fine like this -
>
> <input name="textfield" type="hidden" value="<?php date('Y-m-d H:i:s');
> ?>" />
>
> when that field is being inserted into a SQL DATETIME field.
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.dreamweavermx-templates.com - Template Triage!
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
> ==================
>
>
> "PizzaGood" <PizzaGood@earthlink.com> wrote in message
> news:er252n$1j3$1@forums.macromedia.com...
>>I don't do PHP, but in ASP I use this as the default value of a hidden
>>text field on forms:
>>
>> <input name="textfield" type="hidden" value="<%=now()%>">
>>
>> and then I just insert the record. I only do this if I do not want the
>> actual server time, if I want the server time I set the default of the
>> field on the actual sql server table/field.
>>
>> Would PHP be something like this?????
>>
>> <!--#echo var="DATE_LOCAL"-->
>>
>>
>>
>>
>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>> news:er2442$dc$1@forums.macromedia.com...
>>>I am inserting a form's data into a SQL table. One of the fields in the
>>>table is a Date field. How do I format the field in the form using PHP
>>>so that I get the date and time in that SQL date field?
>>>
>>> --
>>> Murray --- ICQ 71997575
>>> Adobe Community Expert
>>> (If you *MUST* email me, don't LAUGH when you do so!)
>>> ==================
>>> http://www.dreamweavermx-templates.com - Template Triage!
>>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>>> ==================
>>>
>>>
>>> "PizzaGood" <PizzaGood@earthlink.com> wrote in message
>>> news:er23ig$t4f$1@forums.macromedia.com...
>>>> Are you doing this on the SQL Server table as in a Default Value for
>>>> the field?
>>>>
>>>> If so the date should not be truncated .
>>>>
>>>>
>>>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>>>> news:er2319$sgg$1@forums.macromedia.com...
>>>>> It does work, but the time value is truncated off?
>>>>>
>>>>> --
>>>>> Murray --- ICQ 71997575
>>>>> Adobe Community Expert
>>>>> (If you *MUST* email me, don't LAUGH when you do so!)
>>>>> ==================
>>>>> http://www.dreamweavermx-templates.com - Template Triage!
>>>>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>>>>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>>>>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>>>>> ==================
>>>>>
>>>>>
>>>>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>>>>> news:er22o1$s1s$1@forums.macromedia.com...
>>>>>> If I insert a field containing date("Y-m-d H:i:s") as its value into
>>>>>> a SQL field with the Date format, will that work?
>>>>>>
>>>>>> --
>>>>>> Murray --- ICQ 71997575
>>>>>> Adobe Community Expert
>>>>>> (If you *MUST* email me, don't LAUGH when you do so!)
>>>>>> ==================
>>>>>> http://www.dreamweavermx-templates.com - Template Triage!
>>>>>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>>>>>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>>>>>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>>>>>> ==================
>>>>>>
>>>>>>
>>>>>> "gareth" <support@nospam_phploginsuite.co.uk> wrote in message
>>>>>> news:er226o$rb2$1@forums.macromedia.com...
>>>>>>> As David said, NOW() will work in the SQL as the field value.
>>>>>>>
>>>>>>> Alternatively, if you want to use the PHP date command, the correct
>>>>>>> format for date is:
>>>>>>>
>>>>>>> date("Y-m-d")
>>>>>>>
>>>>>>> date and time is:
>>>>>>>
>>>>>>> date("Y-m-d H:i:s")
>>>>>>>
>>>>>>> --
>>>>>>> Gareth
>>>>>>> http://www.phploginsuite.co.uk/
>>>>>>> PHP Login Suite V2 - 34 Server Behaviors to build a complete Login
>>>>>>> system.
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
Thanks! 8)

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"PizzaGood" <PizzaGood@earthlink.com> wrote in message
news:er26c6$338$1@forums.macromedia.com...
> OK...hopefully I was able to help in some way because I REALLY APPRECIATE
> all the help you have given me over time.
>
>
>
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:er2615$2od$1@forums.macromedia.com...
>> It works fine like this -
>>
>> <input name="textfield" type="hidden" value="<?php date('Y-m-d H:i:s');
>> ?>" />
>>
>> when that field is being inserted into a SQL DATETIME field.
>>
>> --
>> Murray --- ICQ 71997575
>> Adobe Community Expert
>> (If you *MUST* email me, don't LAUGH when you do so!)
>> ==================
>> http://www.dreamweavermx-templates.com - Template Triage!
>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>> ==================
>>
>>
>> "PizzaGood" <PizzaGood@earthlink.com> wrote in message
>> news:er252n$1j3$1@forums.macromedia.com...
>>>I don't do PHP, but in ASP I use this as the default value of a hidden
>>>text field on forms:
>>>
>>> <input name="textfield" type="hidden" value="<%=now()%>">
>>>
>>> and then I just insert the record. I only do this if I do not want the
>>> actual server time, if I want the server time I set the default of the
>>> field on the actual sql server table/field.
>>>
>>> Would PHP be something like this?????
>>>
>>> <!--#echo var="DATE_LOCAL"-->
>>>
>>>
>>>
>>>
>>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>>> news:er2442$dc$1@forums.macromedia.com...
>>>>I am inserting a form's data into a SQL table. One of the fields in the
>>>>table is a Date field. How do I format the field in the form using PHP
>>>>so that I get the date and time in that SQL date field?
>>>>
>>>> --
>>>> Murray --- ICQ 71997575
>>>> Adobe Community Expert
>>>> (If you *MUST* email me, don't LAUGH when you do so!)
>>>> ==================
>>>> http://www.dreamweavermx-templates.com - Template Triage!
>>>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>>>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>>>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>>>> ==================
>>>>
>>>>
>>>> "PizzaGood" <PizzaGood@earthlink.com> wrote in message
>>>> news:er23ig$t4f$1@forums.macromedia.com...
>>>>> Are you doing this on the SQL Server table as in a Default Value for
>>>>> the field?
>>>>>
>>>>> If so the date should not be truncated .
>>>>>
>>>>>
>>>>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>>>>> news:er2319$sgg$1@forums.macromedia.com...
>>>>>> It does work, but the time value is truncated off?
>>>>>>
>>>>>> --
>>>>>> Murray --- ICQ 71997575
>>>>>> Adobe Community Expert
>>>>>> (If you *MUST* email me, don't LAUGH when you do so!)
>>>>>> ==================
>>>>>> http://www.dreamweavermx-templates.com - Template Triage!
>>>>>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>>>>>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>>>>>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>>>>>> ==================
>>>>>>
>>>>>>
>>>>>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>>>>>> news:er22o1$s1s$1@forums.macromedia.com...
>>>>>>> If I insert a field containing date("Y-m-d H:i:s") as its value into
>>>>>>> a SQL field with the Date format, will that work?
>>>>>>>
>>>>>>> --
>>>>>>> Murray --- ICQ 71997575
>>>>>>> Adobe Community Expert
>>>>>>> (If you *MUST* email me, don't LAUGH when you do so!)
>>>>>>> ==================
>>>>>>> http://www.dreamweavermx-templates.com - Template Triage!
>>>>>>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>>>>>>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>>>>>>> http://www.macromedia.com/support/search/ - Macromedia (MM)
>>>>>>> Technotes
>>>>>>> ==================
>>>>>>>
>>>>>>>
>>>>>>> "gareth" <support@nospam_phploginsuite.co.uk> wrote in message
>>>>>>> news:er226o$rb2$1@forums.macromedia.com...
>>>>>>>> As David said, NOW() will work in the SQL as the field value.
>>>>>>>>
>>>>>>>> Alternatively, if you want to use the PHP date command, the correct
>>>>>>>> format for date is:
>>>>>>>>
>>>>>>>> date("Y-m-d")
>>>>>>>>
>>>>>>>> date and time is:
>>>>>>>>
>>>>>>>> date("Y-m-d H:i:s")
>>>>>>>>
>>>>>>>> --
>>>>>>>> Gareth
>>>>>>>> http://www.phploginsuite.co.uk/
>>>>>>>> PHP Login Suite V2 - 34 Server Behaviors to build a complete Login
>>>>>>>> system.
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
Murray *ACE* escreveu:
> I have a SQL date field. I want to insert the current date and time into
> it. What format option would I use for the PHP date() function?
>
----------
The best way, I think, to put into a MySQL database a date field, is to
use "timestamp" format.

In MySQL 4.0 the timstamp format is YYYYMMDDhhmmss, that can be
retrieved by:

ereg ( "([0-9]{4})([0-9]{1,2})([0-9]{2})
([0-9]{2})([0-9]{2})([0-9]{2})", $row_recordset['stamp'], $regsg );
echo "$regsg[1] $regsg[2] $regsg[3] ( $regsg[4]h $regsg[5]min
$regsg[6]s )";

"stamp" is the field name!

In MySQL 4.1.5 or superior, the timestamp format is YYYY-MM-DD hh:mm:ss,
that can be retrieved by:

ereg ( "([0-9]{4})-([0-9]{1,2})-([0-9]{2})
([0-9]{2}):([0-9]{2}):([0-9]{2})", $row_rsNVER['stamp'], $regsg );
echo "$regsg[1] $regsg[2] $regsg[3] ( $regsg[4]h $regsg[5]min
$regsg[6]s )";

(sorry for my poor english)
--
zerof
http://www.educar.pro.br/
Apache - PHP - MySQL - Boolean Logics - Project Management
----------------------------------------------------------
Você deve, sempre, consultar uma segunda opinião!
----------------------------------------------------------
Deixe todos saberem se esta informação foi-lhe útil.
----------------------------------------------------------
You must hear, always, one second opinion! In all cases.
----------------------------------------------------------
Let the people know if this info was useful for you!
----------------------------------------------------------
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
Thanks, but I'm already there with the datetime format.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"zerof" <zerof@terra.com.br> wrote in message
news:er2bj5$9b8$1@forums.macromedia.com...
> Murray *ACE* escreveu:
>> I have a SQL date field. I want to insert the current date and time into
>> it. What format option would I use for the PHP date() function?
>>
> ----------
> The best way, I think, to put into a MySQL database a date field, is to
> use "timestamp" format.
>
> In MySQL 4.0 the timstamp format is YYYYMMDDhhmmss, that can be retrieved
> by:
>
> ereg ( "([0-9]{4})([0-9]{1,2})([0-9]{2}) ([0-9]{2})([0-9]{2})([0-9]{2})",
> $row_recordset['stamp'], $regsg );
> echo "$regsg[1] $regsg[2] $regsg[3] ( $regsg[4]h $regsg[5]min
> $regsg[6]s )";
>
> "stamp" is the field name!
>
> In MySQL 4.1.5 or superior, the timestamp format is YYYY-MM-DD hh:mm:ss,
> that can be retrieved by:
>
> ereg ( "([0-9]{4})-([0-9]{1,2})-([0-9]{2})
> ([0-9]{2}):([0-9]{2}):([0-9]{2})", $row_rsNVER['stamp'], $regsg );
> echo "$regsg[1] $regsg[2] $regsg[3] ( $regsg[4]h $regsg[5]min
> $regsg[6]s )";
>
> (sorry for my poor english)
> --
> zerof
> http://www.educar.pro.br/
> Apache - PHP - MySQL - Boolean Logics - Project Management
> ----------------------------------------------------------
> Você deve, sempre, consultar uma segunda opinião!
> ----------------------------------------------------------
> Deixe todos saberem se esta informação foi-lhe útil.
> ----------------------------------------------------------
> You must hear, always, one second opinion! In all cases.
> ----------------------------------------------------------
> Let the people know if this info was useful for you!
> ----------------------------------------------------------


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
Murray *ACE* wrote:

> It works fine like this -
>
> <input name="textfield" type="hidden" value="<?php date('Y-m-d H:i:s'); ?>"
> />
>
> when that field is being inserted into a SQL DATETIME field.
>
You don't need a hidden field, just insert "NOW()" into mysql database
DATETIME column.
Mick
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
Gosh. How sensible....

You're too old for this kind of thought. You didn't hurt yourself, did you?
8)

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Mick White" <himselfBOGUS@mickweb.com> wrote in message
news:er2lok$koe$1@forums.macromedia.com...
> Murray *ACE* wrote:
>
>> It works fine like this -
>>
>> <input name="textfield" type="hidden" value="<?php date('Y-m-d H:i:s');
>> ?>" />
>>
>> when that field is being inserted into a SQL DATETIME field.
>>
> You don't need a hidden field, just insert "NOW()" into mysql database
> DATETIME column.
> Mick


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
Murray *ACE* wrote:
> Gosh. How sensible....
>
> You're too old for this kind of thought.

Hmm. It seems as though the Murray grey matter is being a little slow,
too. Using NOW() is exactly what I suggested six hours ago. ;-)

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
David Powers wrote:

> Murray *ACE* wrote:
>
>> Gosh. How sensible....
>>
>> You're too old for this kind of thought.
>
>
> Hmm. It seems as though the Murray grey matter is being a little slow,
> too. Using NOW() is exactly what I suggested six hours ago. ;-)
>

However, DW won't do it for you, some hand coding is required.

Mick
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
Ew.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Mick White" <himselfBOGUS@mickweb.com> wrote in message
news:er2sko$sla$1@forums.macromedia.com...
> David Powers wrote:
>
>> Murray *ACE* wrote:
>>
>>> Gosh. How sensible....
>>>
>>> You're too old for this kind of thought.
>>
>>
>> Hmm. It seems as though the Murray grey matter is being a little slow,
>> too. Using NOW() is exactly what I suggested six hours ago. ;-)
>>
>
> However, DW won't do it for you, some hand coding is required.
>
> Mick


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007
LATEST
You just didn't explain it the way Mick did - silver tongued devil that he
is....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:er2s48$s50$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> Gosh. How sensible....
>>
>> You're too old for this kind of thought.
>
> Hmm. It seems as though the Murray grey matter is being a little slow,
> too. Using NOW() is exactly what I suggested six hours ago. ;-)
>
> --
> David Powers, Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> Author, "PHP Solutions" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines