HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Time to fix time...

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#648 (In Topic #157)

Fan in action

Time to fix time...

<?php echo date("l, F jS Y @ g:i A",time()-60*60*5+10); ?> (EST)</p>

This is what I have now. I had to add the +10 at the end, for some reason without it it gets 10 mins off of my time. (say it gives me 2:10 when its really 2:20…)

Now, I want to fix it to have Daylight's savings time inputed (sp?) in it.. I tried slapping a +60 at the end (after +10) but it didn't work… I tried to change the +10 to +70 (10 + 60) and it didn't work either.

I looked it up Here and it said I1 would make it DST. (Daylight savings time). It didn't work (I put it along with the ("l, F jS Y @ g:i: A I1",………))

 :unsure:

ocProducts :wub: :wub:

Click here to drop by my website!
Back to the top
 
Posted
Rating:
#650
Avatar

You must have confused yourself because that +10 can't be working as you say. It would have to be +10*60 it add 10 minutes on.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#656

Fan in action

:lol: that +10 does work :lol:

So I should do…?

<?php echo date("l, F jS Y @ g:i A",time()+10+60-60*60*5); ?> (EST)

But that doesn't make sense.. +60 then -60 ? :unsure:

Or should I scrap the +10 there and make it +70 ? :blink:

ocProducts :wub: :wub:

Click here to drop by my website!
Back to the top
 
Posted
Rating:
#657
Avatar

You're confusing me now. It is a case of simple arithmetic with precedence rules.

Back to primary school with an example…

60-60*2

The answer to this is not "2". Multiplication has higher precedence than subtraction, so the 60's there are in no way cancelling each other out.


time() returns the time in seconds.

time()-x
This takes x seconds off the time.

time()-y*60*60
This takes y hours off the time

It is as simple as that.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#658
Avatar

Ok double post. You have made two mistakes I believe…

1) It has 10 minutes off your time simply because one or both clocks are inaccurate. Like yours is 5 minutes slow and the computer is 5 minutes fast.

2) You MUST have had some brackets around the +10 to attach it to a *60 if it worked. Otherwise it would have been adding seconds on, not minutes.
i.e. Not what you gave me – time()-60*60*5+10
Instead you must have – time()-60*(60*5+10)
Also this is the reason why adding on 60 would not work. You'd be adding on one minute, not one hour.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#683

Fan in action

Yah. I figgured out it was in seconds instead of minutes lol.

Doh! :)

Oh well, only one way to learn right?  ;)

ocProducts :wub: :wub:

Click here to drop by my website!
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: