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

Date() question?

LEGEND ,
Apr 01, 2008 Apr 01, 2008

Copy link to clipboard

Copied

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
==================


TOPICS
Server side applications

Views

689
Translate

Report

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 ,
Apr 01, 2008 Apr 01, 2008

Copy link to clipboard

Copied

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/

Votes

Translate

Report

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 ,
Apr 01, 2008 Apr 01, 2008

Copy link to clipboard

Copied

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/

Votes

Translate

Report

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 ,
Apr 01, 2008 Apr 01, 2008

Copy link to clipboard

Copied

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

Votes

Translate

Report

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 ,
Apr 01, 2008 Apr 01, 2008

Copy link to clipboard

Copied


"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


Votes

Translate

Report

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 ,
Apr 01, 2008 Apr 01, 2008

Copy link to clipboard

Copied

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

Votes

Translate

Report

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 ,
Apr 01, 2008 Apr 01, 2008

Copy link to clipboard

Copied

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
>
>

Votes

Translate

Report

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 ,
Apr 01, 2008 Apr 01, 2008

Copy link to clipboard

Copied

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
>

Votes

Translate

Report

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 ,
Apr 01, 2008 Apr 01, 2008

Copy link to clipboard

Copied

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

Votes

Translate

Report

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 ,
Apr 02, 2008 Apr 02, 2008

Copy link to clipboard

Copied


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:fsucnm$5ad$1@forums.macromedia.com...
> 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....

I use the DATEFORMAT as well, esp. since I have one site I do at work that
is Windows/ASP and I am having to migrate to mySQL databases.... the
differing date formats between the database and OS are a bit of a pain. If
I remember, you do mainly PHP stuff, but if you're doing ASP, let me know
and I can post some date tweaks I do for formatting the dates back and
forth.


Votes

Translate

Report

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 ,
Apr 02, 2008 Apr 02, 2008

Copy link to clipboard

Copied

Thanks, Hunter. I do ASP, but not so much anymore. I like PHP much better.

--
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:ft02cr$1gm$1@forums.macromedia.com...
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:fsucnm$5ad$1@forums.macromedia.com...
>> 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....
>
> I use the DATEFORMAT as well, esp. since I have one site I do at work that
> is Windows/ASP and I am having to migrate to mySQL databases.... the
> differing date formats between the database and OS are a bit of a pain.
> If I remember, you do mainly PHP stuff, but if you're doing ASP, let me
> know and I can post some date tweaks I do for formatting the dates back
> and forth.
>

Votes

Translate

Report

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 ,
Apr 02, 2008 Apr 02, 2008

Copy link to clipboard

Copied


"Hunter Elliott" <nospam@gatewaycity.com> wrote in message
news:ft02cr$1gm$1@forums.macromedia.com...
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:fsucnm$5ad$1@forums.macromedia.com...
>> 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....
>
> I use the DATEFORMAT as well, esp. since I have one site I do at work that
> is Windows/ASP and I am having to migrate to mySQL databases.... the
> differing date formats between the database and OS are a bit of a pain.
> If I remember, you do mainly PHP stuff, but if you're doing ASP, let me
> know and I can post some date tweaks I do for formatting the dates back
> and forth.

I'll just go ahead and post it in case there are others doing the ASP/mySQL
thing....

I had one table that had both an "end date" field for when the record would
stop displaying and a "last edited" to show when the entry was last touched
... I did this in the SQL:
SELECT *, DATE_FORMAT(EndDate, '%Y-%m-%d') AS EndDate, DATE_FORMAT(editDate,
GET_FORMAT(DATETIME, 'USA')) AS editDate FROM table.name WHERE recID = ?

Then, I created a couple of functions to replace date() and now() so they'd
get displayed/entered properly into the mySQL database. The "myDate()" and
"myNow()" would replace the date/now calls...

<%
Function myDate()
myDate = Year(Now) & "-" & Right("0" & Month(Now), 2) & "-" & Right("0"
& Day(Now), 2)
End Function
%>

<%
Function myNow()
myNow = Year(Now) & "-" & Right("0" & Month(Now), 2) & "-" & Right("0" &
Day(Now), 2) & " " & Right("0" & Hour(Now), 2) & ":" & Right("0" &
Minute(Now), 2) & ":" & Right("0" & Second(Now), 2)
End Function
%>



Votes

Translate

Report

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 ,
Apr 02, 2008 Apr 02, 2008

Copy link to clipboard

Copied


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:ft02in$1np$1@forums.macromedia.com...
> Thanks, Hunter. I do ASP, but not so much anymore. I like PHP much
> better.

🙂 I don't disagree - but in the corporate world, I don't always have a
choice. I'm trying to get us moved over to more linux/php/mysql instances,
but it's slooooooooow going.


Votes

Translate

Report

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 ,
Apr 03, 2008 Apr 03, 2008

Copy link to clipboard

Copied

Good luck!

--
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:ft0pq8$r4e$1@forums.macromedia.com...
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:ft02in$1np$1@forums.macromedia.com...
>> Thanks, Hunter. I do ASP, but not so much anymore. I like PHP much
>> better.
>
> 🙂 I don't disagree - but in the corporate world, I don't always have a
> choice. I'm trying to get us moved over to more linux/php/mysql instances,
> but it's slooooooooow going.
>

Votes

Translate

Report

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 ,
Apr 04, 2008 Apr 04, 2008

Copy link to clipboard

Copied


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:ft3ld5$74e$1@forums.macromedia.com...
> Good luck!

LOL! With this crowd at my work, I definitely need luck! BTW, are you going
to TODCON again this year, Murray?


Votes

Translate

Report

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 ,
Apr 05, 2008 Apr 05, 2008

Copy link to clipboard

Copied

Hunter:

The timing is not good for me this year! 8( My daughter's HS graduation is
on the 6th of June, and I wouldn't miss a moment of it.

--
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:ft5c5f$5p5$1@forums.macromedia.com...
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:ft3ld5$74e$1@forums.macromedia.com...
>> Good luck!
>
> LOL! With this crowd at my work, I definitely need luck! BTW, are you
> going to TODCON again this year, Murray?
>

Votes

Translate

Report

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 ,
Apr 05, 2008 Apr 05, 2008

Copy link to clipboard

Copied

Murray *ACE* wrote:
> The timing is not good for me this year! 8( My daughter's HS graduation
> is on the 6th of June, and I wouldn't miss a moment of it.

I hope you don't do your TODCon trick of falling asleep. :-p

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

Votes

Translate

Report

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 ,
Apr 07, 2008 Apr 07, 2008

Copy link to clipboard

Copied


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:ft7nc3$p6c$1@forums.macromedia.com...
> Hunter:
>
> The timing is not good for me this year! 8( My daughter's HS graduation
> is on the 6th of June, and I wouldn't miss a moment of it.

as well you shouldn't! I do hope the graduation is great for her!


Votes

Translate

Report

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 ,
Apr 07, 2008 Apr 07, 2008

Copy link to clipboard

Copied

LATEST

"David Powers" <david@example.com> wrote in message
news:ft82eu$704$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> The timing is not good for me this year! 8( My daughter's HS graduation
>> is on the 6th of June, and I wouldn't miss a moment of it.
>
> I hope you don't do your TODCon trick of falling asleep. :-p

I'll try an uphold that honor at TODCON for him 🙂


Votes

Translate

Report

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