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

DateDiff():well cfml code is correct

New Here ,
Nov 17, 2010 Nov 17, 2010

<cfset today = DateDiff("s", Now()+9*60*60, CreateDate(1970,1,1)) />

this is correct way get the seconds from unix time...?

I tried put this number [today] in database(MySQL) and appear with PHP but shows..21:40 Thu 08 Jul 1976 time, well?

php:

    if ($LastVisitDate1==NULL) { $LastVisitDate = "NOT SETUP"; } else { $LastVisitDate = date("H:i D d M Y", $LastVisitDate1); }

<?=$LastVisitDate  ?>

well cfml code is correct?

Message was edited by: 123polis123

TOPICS
Getting started
673
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 ,
Nov 17, 2010 Nov 17, 2010

What data type is the column in the DB?  Why are you trying to store a date as "seconds from the unix epoch" rather than just as a date.  If you store it as a date, it'll work in all of CF, MySQL & PHP without any arsing around.

--

Adam

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
New Here ,
Nov 17, 2010 Nov 17, 2010
bigint(20)
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 ,
Nov 17, 2010 Nov 17, 2010

Your cfml code is not correct.  First, you have the two dates in the wrong order.  Second, the extra math is giving you an incorrect answer.

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
New Here ,
Nov 17, 2010 Nov 17, 2010

<cfset today = DateDiff("s", CreateDate(1970,1,1), Now()) />

well this is correct? what if I want add to server time 9hours?

do you know any ready made script/component, cfml or php, that get visitors country by IP?

for administrative statistics.....

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
Guide ,
Nov 17, 2010 Nov 17, 2010

Have you tried Googling for "visitors country by IP coldfusion"? Brings up some pretty promising links.

So you want to add to a date? How about dateAdd()? It's all in the docs hidden under Functions | Date and Time functions.

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
Community Expert ,
Nov 21, 2010 Nov 21, 2010
LATEST

<cfset todayDatePlus9hours = dateadd("h",9,now())>
<cfset secondsSince1970 = DateDiff("s", createDatetime(1970,1,1,0,0,0), todayDatePlus9hours) >
<cfoutput>#secondsSince1970#</cfoutput>

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
Resources