Category Archives: General

Get current time of any country

//To find out the current time in any country, factoring in Daylight saving, we can use the following code

/* We generate all the timezones so we can pick as and when necessary */
public static readonly ReadOnlyCollection<TimeZoneInfo> TimeZones = TimeZoneInfo.GetSystemTimeZones();

/* Get the timezone of the exchange currently in operation */
TimeZoneInfo info = TimeZoneInfo.FindSystemTimeZoneById(“Indian Standard Time”);

/* Get the offset */
var dto = DateTimeOffset.UtcNow;

/*Now get the current time for the exchange */
var currentTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dto, info.Id);

Advertisements

Post via Email to a WordPress blog

We need to follow the following steps to post via email from WordPress blog:

  1. I was using a gmail account. The domain was also managed by google but this shouldn’t matter even if it’s a regular gmail account. Need to make sure that POP/IMAP access is enabled. This is done in settings page.
  2. Make sure this is a fresh new email setup exclusively for this purpose. Don’t use your regular daily email account because every mail in inbox will get picked up for posting
  3. Need to make sure that the the access to less secure app is turned on. Its available here: https://www.google.com/settings/security/lesssecureapps. This will not work if the email account is setup for 2-step verification
  4. I installed a plugin called Postie on the wordpress blog and configured this plugin for post via email on its settings page.
  5. On this settings page, Mailserver tab, I entered the new email account along with other settings like IMAP server name, port and login credentials
  6. Also on the settings page, in message tab, i set changed two settings: Filter newlines = Yes and Replace newline characters with html line breaks (<br />)  = Yes. This allows the line breaks to be preserved the way they are in the original email.
  7. I was using cpanel on my web hosting server. I had to setup a cron job. This was setup using the following command: wget –user=[username] –password='[password]’ http://%5Bmysite%5D/?postie=get-mail. I have set up username/password to access this site so i had to pass this in my wget command. I set this to work once per hour.