Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Share price display

Featured Replies

Hello all,

 

Does anyone know how I can include a companies share information on a web page. I have found a script that will display info from the Yahoo finance portal, but the date format is the wrong way round ie US. The info isn't quite what the client wants either - they are thinking the feed should come from Bloomberg or Reuters??? If anyone can help put me straight I would be eternally grateful!

 

Andrew

Try contacting the London Stock Exchange, they must have some dort of feeds you can use?

 

Otherwise try the Yahoo *UK* Finance portal

  • Author

Yes, looks like I'll have to use a third party service of some kind. The script I found imports data from the Yahoo finance site in the US from a CSV file. I can't find a UK equivalent and cannot change the date to UK format ie day/month/year instead of month/day/year :(

 

(To be honest this is a part of my job I find a bit frustrating because I can spend hours looking for a solution for something and never need it again :( )

(To be honest this is a part of my job I find a bit frustrating because I can spend hours looking for a solution for something and never need it again :( )

You're not alone - That goes for all of us!

The only decent services are those that are paid.

 

If you post the code for pulling the data from the Yahoo via CSV we can likely find a solution to the date issue.

  • Author

Many thanks.

 

This is the code that I am using provided originally by Kevin Kazimir:

 

(I've stripped out the bits that aren't relevant:)

 

<?php

 

$text = file_get_contents("http://download.finance.yahoo.com/d/quotes.csv?s=" . $stockSymbol . "&f=sl1d1t1c1ohgv&e=.csv");

 

$stockInfo = explode(",", $text);

 

$sssLastTrade = $stockInfo[1];

$sssLastTrade = number_format($sssLastTrade, 2);

 

$sssDate = substr($stockInfo[2], 1);

$sssDate = substr($sssDate, 0, -1);

 

$sssTime = substr($stockInfo[3], 1);

$sssTime = substr($sssTime, 0, -1);

 

$sssChange = $stockInfo[4];

 

$sssOpen = $stockInfo[5];

$sssOpen = number_format($sssOpen, 2);

 

$sssTodayMax = $stockInfo[6];

$sssTodayMax = number_format($sssTodayMax, 2);

 

$sssTodayMin = $stockInfo[7];

$sssTodayMin = number_format($sssTodayMin, 2);

 

$sssVolume = $stockInfo[8];

 

 

?>

 

Is it possible to add some code that flips month/day/year to day/month/year?

 

Andrew

Change:

$sssDate = substr($stockInfo[2], 1);
$sssDate = substr($sssDate, 0, -1);

 

to:

$sssDate = trim($stockInfo[2], '"');
$sssDate = date("d M y", strtotime($sssDate));

 

Change d M y to the date format you require, using http://php.net/date

  • Author

LIFE SAVER!!!!!!!

 

Thanks so much for your time - works perfectly.

 

Andrew

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.