PDA

View Full Version : PHP echo date


starapple
02-01-2008, 02:16 AM
Hi,

I'd like to echo the date on the head of my pages using this code: echo date('W, o');

How do I do that?

Thanks.

northlandadv
02-01-2008, 03:17 AM
This might work:

http://www.vivvo.net/resources/how-to/php-includes.html

Just create an external PHP file (echo.php) with the echo code included, and the use the Vivvo php include function to pull the file into the place of your choice.

northlandadv
02-01-2008, 03:35 AM
Tried this, and couldn't get it to work.

Hey Vivvo developers, can you help out? Is there a get.date object we can use to pull the server date, etc?

starapple
02-01-2008, 06:19 PM
This might work:

http://www.vivvo.net/resources/how-to/php-includes.html

Just create an external PHP file (echo.php) with the echo code included, and the use the Vivvo php include function to pull the file into the place of your choice.

Tried that and it didn't work. Placed it above the search box on the front page and the search disappeared and the date didn't show. Placed it below and still a no show. This is from location box/header.tpl.

I know the script works when I open it in a browser.

northlandadv
02-01-2008, 07:59 PM
Same thing happened for me. Works fine on it's own, but not as an include.

northlandadv
02-02-2008, 02:35 PM
Vivvo team: any feedback on this?

starapple
02-04-2008, 03:50 PM
I'm wondering whether it has to do with the version of PHP. I switched to PHP 5 last night and the include is showing today.

DRIVE
03-31-2010, 06:10 PM
I searched every post in this site for "date" and read them all. Unless I missed something, I didnt find a single post that described how to get one of the MOST COMMON things people put onto a website -- todays date!!

All I found was a bunch of freakin javascripts to display the date -- hmmm -- I may have wrote one :)

Oh, before I did that, I spent over an hour hunting in the VTE for a string you could use in a template <vet:value select.... yada yada... nothing. If I missed it, PLEASE point me in the right direction.

Anywho --- for God's sake ladies, we are using PHP!! WTF are we doing using javascripts to display the date for when just ONE very SHORT line of code would do the trick???

I got fed up with this and remember hunting for the workaround a few years ago... the only answer? A long javascript. In my recent travels, this finally ticked me off so this is my workaround. IF YOU USE OTHER LANGUAGE BESIDES ENGLISH, OR YOU DONT USE ENGLISH AT ALL, THIS NEEDS TO BE IN WHATEVER LANGUAGE FILE(s) YOU DO USE. ALSO, YOU WILL HAVE TO R E M E M B E R to MAKE THE UPDATE FOR EVERY FREAKING TIME VIVVO HAS A NEW VERSION THAT UPDATES THE LANGUAGE FILE. HOW FREAKIN NICE.

Anyway, here it is. I am done shouting however it will be a while until I am not TICKED OFF >:|

There is probably a better way but this was the most common PHP file I could find to do this method:

1) Open /YOUR_VIVVO_DIR/lang/english.php and at the top below the notice you will see this:
define ('VIVVO_DB_COLLATION', 'utf8_unicode_ci');
define ('VIVVO_LANG_CODE' , 'en-US');

2) Add the line in red:
define ('VIVVO_DB_COLLATION', 'utf8_unicode_ci');
define ('VIVVO_LANG_CODE' , 'en-US');
define ('TODAYS_BLANKING_DATE', date('F j, Y'));

3) Wherever you want the date, use this this code. Wrap it in DIV tags or whatever suits your fancy. I put this example in the search.tpl:
<div id="date">
<vte:value select="{TODAYS_BLANKING_DATE}" />
</div>

Now go do some work. If you want to change the format it is very easy:
http://php.net/manual/en/function.date.php

Enjoy :)

... hope i dont get banned.... I need some CRED people! lol
If there is a way to do this easily in VTE or any other method, I will belly crawl asking for mercy and I will never ever get angry about "TODAY" again :D




-

bobster65
04-01-2010, 01:50 AM
I'd put it in config.php, but thats just me.

DRIVE
04-01-2010, 02:21 AM
That's a great idea!

That file is much less likely to get changed much if at all

Where were you back in 08?

So that's the plan. That's a great spot to store a bunch of things.

Thanks!

bobster65
04-01-2010, 05:19 PM
That's a great idea!

That file is much less likely to get changed much if at all

Where were you back in 08?

So that's the plan. That's a great spot to store a bunch of things.

Thanks!

I'm around now :D

and ya, config.php is a much better place for extra globals/constants like that.