Copy link to clipboard
Copied
<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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
bigint(20) |
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
<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.....
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
<cfset todayDatePlus9hours = dateadd("h",9,now())>
<cfset secondsSince1970 = DateDiff("s", createDatetime(1970,1,1,0,0,0), todayDatePlus9hours) >
<cfoutput>#secondsSince1970#</cfoutput>