1. Go to this page and download the library: Download sourcepot/asset library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sourcepot / asset example snippets
// asset object creation
$asset = new Asset(100000,'GBP',new \DateTime("2016-08-31T12:00:00+01:00"));
// setting a new unit, converting GBP to USD @2016-08-31
$asset->convert2unit('USD');
// will show 131264.20 USD (2016-08-31T12:00:00+01:00), the asset property dateTime was adjusted to the exchange rate dateTime
echo $asset;
$assetArr = $asset->getArray();
/* The array content is:
object {11}
ISO 8601: 2015-08-21T23:00:00+01:00
RFC 2822: Fri, 21 Aug 2015 23:00:00 +0100
Timestamp: 1440194400
Currency: USD
Amount: 10.06
Amount de: 10,06
Amount (US): USD 10.06
Amount (DE): 10,06 USD
Amount (DE full): 10,06 USD
Amount (FR): 10.06 USD
Warning: W001: "USD" rate for "2015-08-22" missing, rate dated "2015-08-21" used.
*/
$asset->addAssetString('1000000 JPY');
// The new asset is 107373.00 GBP (2016-08-31T12:00:00+01:00), the date is set to the exchange rate date
echo $asset;
$asset->setFromString('AU$ 12.345,67');
// The new asset is 12345.67 AUD (2025-02-22T15:41:26+01:00)
echo $asset;
$dateTimeParserObj=new DateTimeParser();
$dateTimeParserObj->setFromString('Meeting on August 2., 2014 at 12:34:56 (Asia/Tokyo)');
// the uptated DateTimeParser object returns 2014-08-02T05:34:56+02:00
echo $dateTimeParserObj;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.