i tried to change my joomla 3.2 article created date to shown as "created from since"
EX: created from 2 hours ago, created from 2 weeks ago.
can you help me ?
You should be able to do this with language override and php date format
https://stackoverflow.com/a/11728790/6096
$post_date = '13436714242'; // strtotime();
$now = time();
// will echo "2 hours ago" (at the time of this post)
echo timespan($post_date, $now) . ' ago';
So for joomla dates edit the template overrides you need
echo timespan( strtotime($this->item->publish_up, $now) ) . ' ago';
echo timespan( strtotime($this->item->modified, $now) ) . ' ago';
echo timespan( strtotime($this->item->created, $now) ) . ' ago';
As you first need to turn the date back into a timestamp. I dont think there will be just one place to do it so you will have to look for several.
Related
Hello I am having a problem retrieving a value from this link.
So far I've been using this line of code.
$str = "https://gdata.youtube.com/feeds/api/videos/VdbUBcOCU_A";
$blow =(explode("'",$str));
print_r($blow);
And echoes out "Array" would appreciate any help how to retrieve a value from the link. Thanks.
If I am correct, you are using PHP?
Suggest you use Google PHP client library at https://developers.google.com/youtube/2.0/developers_guide_php
For your case, see https://developers.google.com/youtube/2.0/developers_guide_php#Video_Entry_Contents
$videoEntry = $yt->getVideoEntry('VdbUBcOCU_A');
printVideoEntry($videoEntry);
function printVideoEntry($videoEntry)
{
echo 'Video: ' . $videoEntry->getVideoTitle() . "\n";
echo 'Video ID: ' . $videoEntry->getVideoId() . "\n";
echo 'Updated: ' . $videoEntry->getUpdated() . "\n";
}
== UPDATE ===
So I realized that Sublime already has a command for adding comments. So if I have code inserted like this:
comment = " ----------------------------------------" + '\n'
comment += " " + title + '\n'
comment += " #author " + author + '\n'
comment += " #url " + url + '\n'
comment += " ---------------------------------------" + '\n'
comment = self.view.run_command('toggle_comment')
code = items['code']
layout = comment + code
self.view.replace(edit, sel[0], layout)
How do I get the command to work so that it comments out the comment variable? Thanks.
Initial Question
I am creating a plugin for Sublime Text 2 and want to make sure that when it inserts/replaces code it inserts comments as well, but to do this I need for it to insert the correct comment types for the various languages. I know that I can run the following command:
view.settings().get('syntax')
And that will return something like this:
Packages/Python/Python.tmLanguage
Is there a way to have it return just PHP, Python, C++, etc.
I'm sure I could do a substring command in Python, but since I can see an easy way of seeing all file settings I wanted to make sure there wasn't a quick easy way of doing this. Thanks for the help.
Are you looking for scope_name ?
scope_name(point) | String | Returns the syntax name assigned to the character at the given point.
I have a requirement to export Windows Event logs to CSV from our production environment periodically.
I have a simple XML Config file containing a list of machines I need the events from, and a list of Event Ids that I need to retrieve.
From here I'm looping through each machine name in turn, and then each event Id to retrieve the logs and then export to CSV. I'd like one CSV per machine per execution.
Once I've worked out all my variables the PS Command is quite simple to retrieve the log for one Event Id
foreach ($machine in $config.Configuration.Machines.Machine)
{
$csvname=$outputlocation + $machine.Value + "_" + $datestring + ".csv"
foreach ($eventid in $config.Configuration.EventIds.EventId)
{
Get-WinEvent -ComputerName $machine.Value -ErrorAction SilentlyContinue -FilterHashTable #{Logname='Security';ID=$eventid.Value} | where {$_.TimeCreated -gt $lastexecutiondate} | export-csv -NoClobber -append $csvname
}
}
Execpt I'm unable to append to a CSV each time, PS 2.0 apparently does not support this. I've tried extracting all Event Ids at once but this seems to be a bit long winded and may now allow use of a config file, but I'm fairly new to PowerShell so I haven't had much luck.
I also need to specify multiple LogNames (System, Security and Application), and would prefer to run one statement as opposed to the same statement 3 times and appe but I'm unsure of how to do this.
Unfortunately at this point Google has me running in circles.
The following is something I culled together to allow me to export the prior 24 hours of events for select event logs - I'm going to create a scheduled task out of it so it pulls a daily.
Hope this helps someone else...
$eventLogNames = "Application", "Security", "System", "Windows PowerShell"
$startDate = Get-Date
$startDate = $startDate.addDays(-1).addMinutes(-15)
function GetMilliseconds($date)
{
$ts = New-TimeSpan -Start $date -End (Get-Date)
[math]::Round($ts.TotalMilliseconds)
}
$serverName = get-content env:computername
$serverIP = gwmi Win32_NetworkAdapterConfiguration |
Where { $_.IPAddress } | # filter the objects where an address actually exists
Select -Expand IPAddress | # retrieve only the property *value*
Where { $_ -notlike '*:*' }
$fileNameDate = Get-Date -format yyyyMMddhhmm
$endDate = Get-Date
$startTime = GetMilliseconds($startDate)
$endTime = GetMilliseconds($endDate)
foreach ($eventLogName in $eventLogNames)
{
Write-Host "Processing Log: " $eventLogName
<# - Remove comment to create csv version of log files
$csvFile = $fileNameDate + "_" + $serverIP +"_" + $eventLogName + ".csv"
Write-Host "Creating CSV Log: " $csvFile
Get-EventLog -LogName $eventLogName -ComputerName $serverName -After $startDate -ErrorAction SilentlyContinue | Sort MachineName, TimeWritten | Select MachineName, Source, TimeWritten, EventID, EntryType, Message | Export-CSV $csvFile #ConvertTo-CSV #Format-Table -Wrap -Property Source, TimeWritten, EventID, EntryType, Message -Autosize -NoTypeInformation
#>
$evtxFile = $fileNameDate + "_" + $serverIP + "_" + $eventLogName + ".evtx"
Write-Host "Creating EVTX Log: " $evtxFile
wevtutil epl $eventLogName $evtxFile /q:"*[System[TimeCreated[timediff(#SystemTime) >= $endTime] and TimeCreated[timediff(#SystemTime) <= $startTime]]]"
}
Why do I get Failed to export log Security. The specified query is invalid. I get this for each type of event log (system, application etc). This happens only to evtx export. I get the csv file tho`....
Need help with part of this PS script. I am basically need to read the content of a file (look for word imported). New file is generated every day with the format power_XX.log
XX represents the day of the month.
Don't know what I am overlooking , but if the file exists and word "imported" is found it should generated a true.
Thanks in advance
************************
#today is a working day
$today = (get-date).day
$fileofday = Get-ChildItem -Path \\noctest1\c$\temp\*.log ('power_' + $today + '.log')
if ($fileofday -and (select-string -Path '\\noctest1\c$\temp\*.log ($fileofday)'-Pattern 'imported' -Quiet))
*******************************************
$today = (get-date).day;
$filePath = join-path -path "\\noctest1\c`$\temp" -childpath $("power_$today.log");
$importedFound = $false;
$todayFileExists = test-path $filePath
if ($todayFileExists) {
$importedFound = select-string $filePath -pattern "imported" -quiet;
}
$importedFound is now true if the file was found and contains "imported", otherwise it's false.
I want to get list of installed windows hotfix and updates. I use script below:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colQuickFixes = objWMIService.ExecQuery _
("Select * from Win32_QuickFixEngineering")
Set objDateTime = CreateObject("WbemScripting.SWbemDateTime")
For Each objQuickFix in colQuickFixes
Wscript.Echo "Computer: " & objQuickFix.CSName
Wscript.Echo "Description: " & objQuickFix.Description
Wscript.Echo "Hot Fix ID: " & objQuickFix.HotFixID
If Not (IsNull(objQuickFix.InstallDate) Or _
IsEmpty(objQuickFix.InstallDate)) Then
objDateTime.Value = objQuickFix.InstallDate
Wscript.Echo "Installation Date: " & objDateTime.GetFileTime
Else
WScript.Echo "Install Date Type: " &
TypeName(objQuickFix.InstallDate)
End If
Wscript.Echo "Installed By: " & objQuickFix.InstalledBy
Next
When I run this script I get Error message:
Syntax error
Error Code 800A03EA
What's wrong in this piece of code? Thanks!
Sorry if my English is not perfect.
You are missing the line continuation character (_) here:
''# -----------
''# |
''# \/
WScript.Echo "Install Date Type: " & _
TypeName(objQuickFix.InstallDate)
Either add it or put the code in a singe line:
WScript.Echo "Install Date Type: " & TypeName(objQuickFix.InstallDate)