# 月初(BOM, BeginningOfMonth)

# Bash

function get_bom
{
    BOM=`date +%Y%m01 -d $1`
    echo $BOM
}
get_bom 20150509

# PHP

function getBOM($d) {
    return new DateTime($d->format('Y-m-01'));
}

# Python

def get_bom(d):
  return d - datetime.timedelta(d.day - 1)

# Ruby

def get_bom(d)
  return d - d.day + 1
end

[ 📩 ご意見 ]