Skip to main content
Inspiring
April 1, 2008
Question

Date() question?

  • April 1, 2008
  • 18 replies
  • 721 views
If I have a timestamp field, why doesn't this work?

<?php echo date("F j, Y, g:i a",$row_rsLoanRates['newRatesTimestamp']); ?>

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


This topic is closed to new replies. Start a new post to keep the conversation going.

18 replies

Inspiring
April 1, 2008
On 01 Apr 2008 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:

> Got it.
>
> $query_rsLoanRates = "SELECT *,DATE_FORMAT(newRatesTimestamp, '%W,
> %e %M, %Y, %r') as foo FROM cma_newRates2 ORDER BY newRatesTimestamp
> DESC LIMIT 1";
>
> ...
>
> <?php echo $row_rsLoanRates['lastUpdate'] ?>

<?php echo $row_rsLoanRates['foo'] ?>, No?

> Thanks, Joe!

NP. My personal preference, particularly when it comes to dates, is to
do whatever I can in SQL before it hits PHP. I find it's easier.

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/contact.php
Inspiring
April 1, 2008
Got it.

$query_rsLoanRates = "SELECT *,DATE_FORMAT(newRatesTimestamp, '%W, %e %M,
%Y, %r') as foo FROM cma_newRates2 ORDER BY newRatesTimestamp DESC LIMIT 1";

...

<?php echo $row_rsLoanRates['lastUpdate'] ?>

Thanks, Joe!

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:fsucm7$596$1@forums.macromedia.com...
> How do I then use that variable, Joe? Now, I have this -
>
> $query_rsLoanRates = "SELECT * FROM cma_newRates2
> DATE_FORMAT(newRatesTimestamp, '%W, %e %M, %Y') as LASTUPDATE ORDER BY
> newRatesTimestamp DESC LIMIT 1";
>
> And I want to use that LASTUPDATE constant in a PHP echo.
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> ==================
>
>
> "Joe Makowiec" <makowiec@invalid.invalid> wrote in message
> news:Xns9A73B70367BEmakowiecatnycapdotrE@216.104.212.96...
>> On 01 Apr 2008 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:
>>
>>> Hmm - so what I have in the database is a field that is a timestamp
>>> field. How can I now use that 'timestamp' to produce more attractive
>>> output?
>>
>> http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format
>>
>> SELECT field1, field2,
>> DATE_FORMAT(newRatesTimestamp, '%W, %e %M, %Y') as myFormattedDate
>> FROM myTable ...
>>
>> --
>> Joe Makowiec
>> http://makowiec.net/
>> Email: http://makowiec.net/contact.php
>

Inspiring
April 1, 2008
Hunter:

Thanks for that! I'm running down the road that Joe showed me. If I hit a
pothole, I'll give this a try....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"Hunter Elliott" <nospam@gatewaycity.com> wrote in message
news:fsub9e$3v0$1@forums.macromedia.com...
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:fsuapg$3el$1@forums.macromedia.com...
>> Hmm - so what I have in the database is a field that is a timestamp
>> field. How can I now use that 'timestamp' to produce more attractive
>> output?
>>
>
> Murray, Felix has an extension for formatting dates/times for PHP/mySQL
> over at http://www.felixone.it
> it's his PHP Date Time Formats - here's the text from Extension Manager...
>
> "This extension allows to format date and time data source values in
> various languages.
> (Only for PHP MySQL model).
>
> by: Felice Di Stefano - (All rights reserved)
> http://www.felixone.it
>
> Format groups:
> - Generic > these are short formats using only decimal numbers
> - Fixed EN > these are long formats fixed anyway in English language
> - International > these are long formats which language can be managed by
> the Locale ID sb
>
> Included server behavior:
> - Locale ID > only editable but directly managed by the formats
>
> You can access the format options from the data source Bindings panel.
> Click the source on the page, then click Format on the selected source in
> the Bindings panel.
> The Locale ID server behavior will be automatically applied with a System
> Default value, when
> you apply an international format you may doubleclick it to define a
> specific ID if desired.
> Note: If the format functions are not yet on the page it is strictly
> recommended to apply it
> from the Bindings panel. For text field values use the inspector.
>
> After this installation it might be required to re-install the Felixone's
> "PHP Numeric Formats"
> in case you'll find the numeric formats menu broken."
>
> Don't know if this is helpful for you or not... hopefully it is :)
>
> Hunter
>
>

Inspiring
April 1, 2008
How do I then use that variable, Joe? Now, I have this -

$query_rsLoanRates = "SELECT * FROM cma_newRates2
DATE_FORMAT(newRatesTimestamp, '%W, %e %M, %Y') as LASTUPDATE ORDER BY
newRatesTimestamp DESC LIMIT 1";

And I want to use that LASTUPDATE constant in a PHP echo.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"Joe Makowiec" <makowiec@invalid.invalid> wrote in message
news:Xns9A73B70367BEmakowiecatnycapdotrE@216.104.212.96...
> On 01 Apr 2008 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:
>
>> Hmm - so what I have in the database is a field that is a timestamp
>> field. How can I now use that 'timestamp' to produce more attractive
>> output?
>
> http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format
>
> SELECT field1, field2,
> DATE_FORMAT(newRatesTimestamp, '%W, %e %M, %Y') as myFormattedDate
> FROM myTable ...
>
> --
> Joe Makowiec
> http://makowiec.net/
> Email: http://makowiec.net/contact.php

Inspiring
April 1, 2008

"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:fsuapg$3el$1@forums.macromedia.com...
> Hmm - so what I have in the database is a field that is a timestamp field.
> How can I now use that 'timestamp' to produce more attractive output?
>

Murray, Felix has an extension for formatting dates/times for PHP/mySQL over
at http://www.felixone.it
it's his PHP Date Time Formats - here's the text from Extension Manager...

"This extension allows to format date and time data source values in various
languages.
(Only for PHP MySQL model).

by: Felice Di Stefano - (All rights reserved)
http://www.felixone.it

Format groups:
- Generic > these are short formats using only decimal numbers
- Fixed EN > these are long formats fixed anyway in English language
- International > these are long formats which language can be managed by
the Locale ID sb

Included server behavior:
- Locale ID > only editable but directly managed by the formats

You can access the format options from the data source Bindings panel.
Click the source on the page, then click Format on the selected source in
the Bindings panel.
The Locale ID server behavior will be automatically applied with a System
Default value, when
you apply an international format you may doubleclick it to define a
specific ID if desired.
Note: If the format functions are not yet on the page it is strictly
recommended to apply it
from the Bindings panel. For text field values use the inspector.

After this installation it might be required to re-install the Felixone's
"PHP Numeric Formats"
in case you'll find the numeric formats menu broken."

Don't know if this is helpful for you or not... hopefully it is :)

Hunter


Inspiring
April 1, 2008
On 01 Apr 2008 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:

> Hmm - so what I have in the database is a field that is a timestamp
> field. How can I now use that 'timestamp' to produce more attractive
> output?

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format

SELECT field1, field2,
DATE_FORMAT(newRatesTimestamp, '%W, %e %M, %Y') as myFormattedDate
FROM myTable ...

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/contact.php
Inspiring
April 1, 2008
Hmm - so what I have in the database is a field that is a timestamp field.
How can I now use that 'timestamp' to produce more attractive output?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"David Powers" <david@example.com> wrote in message
news:fsuad8$2rp$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> If I have a timestamp field, why doesn't this work?
>>
>> <?php echo date("F j, Y, g:i a",$row_rsLoanRates['newRatesTimestamp']);
>> ?>
>
> MySQL timestamps are based on the real date, not on the number of seconds
> since 1/1/1970. You cannot use them directly with the PHP date() function.
> Use DATE_FORMAT() in your SQL instead.
>
> --
> David Powers, Adobe Community Expert
> Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
> Author, "PHP Solutions" (friends of ED)
> http://foundationphp.com/

Inspiring
April 1, 2008
Murray *ACE* wrote:
> If I have a timestamp field, why doesn't this work?
>
> <?php echo date("F j, Y, g:i a",$row_rsLoanRates['newRatesTimestamp']); ?>

MySQL timestamps are based on the real date, not on the number of
seconds since 1/1/1970. You cannot use them directly with the PHP date()
function. Use DATE_FORMAT() in your SQL instead.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/